コード例 #1
0
ファイル: Rent.cs プロジェクト: nofuture-git/31g
        /// <summary>
        /// http://www.deptofnumbers.com/rent/us/
        /// </summary>
        /// <param name="dt"></param>
        /// <returns></returns>
        public static Pecuniam GetAvgAmericanRentByYear(DateTime? dt)
        {
            var eq = new LinearEquation {Intercept = -13340, Slope = 7.1091};

            var year = dt.GetValueOrDefault(DateTime.Today).ToDouble();

            return new Pecuniam( (decimal)eq.SolveForY(year));
        }
コード例 #2
0
ファイル: MathTests.cs プロジェクト: nofuture-git/31g
        public void TestLinearEquation()
        {
            //y = 0.1056x - 181.45
            var myEq = new LinearEquation {Intercept = -181.45, Slope = 0.1056};
            var dob = 1974.477451;
            var x = myEq.SolveForY(dob);
            System.Diagnostics.Debug.WriteLine(x);
            Assert.IsTrue(x > 27 && x < 28);

            var y = myEq.SolveForX(27.0548188256);
            System.Diagnostics.Debug.WriteLine(y);
            Assert.AreEqual(dob, y);
        }
コード例 #3
0
ファイル: NAmerUtil.cs プロジェクト: nofuture-git/31g
        /// <summary>
        /// Returns a new <see cref="IPerson"/> representing a 
        /// parent of the specified <see cref="gender"/> having a realistic age 
        /// from the <see cref="childDob"/>.
        /// </summary>
        /// <param name="childDob"></param>
        /// <param name="eq"></param>
        /// <param name="gender"></param>
        /// <returns></returns>
        public static IPerson SolveForParent(DateTime childDob, LinearEquation eq, Gender gender)
        {
            //move to a date 1 - 6 years prior the Person's dob
            var dtPm = childDob.AddYears(-1 * Etx.IntNumber(1, 6)).AddDays(Etx.IntNumber(1, 360));

            //calc the age of marriable person at this time
            var avgAgeCouldMarry =
                eq.SolveForY(dtPm.ToDouble());

            //move the adjusted child-dob date back by calc'ed years
            var parentDob = dtPm.AddYears(Convert.ToInt32(Math.Round(avgAgeCouldMarry, 0))*-1);

            var aParent = new NorthAmerican(parentDob, gender, false, false);
            return aParent;
        }