Пример #1
0
        /// <summary>
        /// Calculates the z-score for a growth measure using a specified value.
        /// </summary>
        /// <param name="indicator">The growth indicator</param>
        /// <param name="measurement">The specified measured value</param>
        /// <param name="ageInDays">The age in total days</param>
        /// <param name="sex">Human sex designation per ISO/IEC 5218 code</param>
        /// <returns>Returns the z-score for a growth measure using a specified value.</returns>
        public double CalculateZScore(Indicator indicator, double measurement, double ageInDays, Sex sex)
        {
            WHO2006 who2006 = new WHO2006();
            double  z       = 0.0;

            if (who2006.TryCalculateZScore(indicator, measurement, ageInDays, sex, z: ref z))
            {
                return(z);
            }

            return(z);
        }
Пример #2
0
        /// <summary>
        /// Calculates both the Zscore and Percentile.
        /// </summary>
        /// <param name="indicator">The growth indicator</param>
        /// <param name="measurement">The specified measured value</param>
        /// <param name="ageInDays">The age in total days</param>
        /// <param name="sex">Human sex designation per ISO/IEC 5218 code</param>
        /// <returns>Returns the z-score and percentile for a growth measure using a specified value.</returns>
        public Tuple <double, double> GetScore(Indicator indicator, double measurement, double ageInDays, Sex sex)
        {
            WHO2006 who2006 = new WHO2006();

            double z = 0.0;
            double p = 0.0;

            if (who2006.TryCalculateZScore(indicator, measurement, ageInDays, sex, z: ref z))
            {
                p = StatisticsHelper.CalculatePercentile(z);
            }

            z = Math.Round(z, 2);
            p = Math.Round(p, 1);

            return(Tuple.Create(z, p));
        }
Пример #3
0
        static void Main(string[] args)
        {
            var cdc2000 = new CDC2000();
            var who2006 = new WHO2006();
            var who2007 = new WHO2007();

            // Calculates a BMI-for-age z-score using CDC 2000
            double ageMonths = 26;
            double z         = 0.0;
            double bmi       = 18.0;

            if (cdc2000.TryCalculateZScore(indicator: Indicator.BodyMassIndexForAge, measurement1: bmi, measurement2: ageMonths, sex: Sex.Female, z: ref z))
            {
                double p = StatisticsHelper.CalculatePercentile(z);

                z = Math.Round(z, 2);
                p = Math.Round(p, 2);

                Console.WriteLine($"[CDC 2000] - {ageMonths} month old female with BMI = {bmi} has z-score of {z} and percentile of {p}");
            }
            else
            {
                Console.WriteLine($"{ageMonths} is a valid age in months for the CDC 2000 BMI-for-age indicator.");
            }

            // Calculates a BMI-for-age z-score using WHO 2006
            double ageDays = 32;

            bmi = 16;

            if (who2006.TryCalculateZScore(indicator: Indicator.BodyMassIndexForAge, measurement1: bmi, measurement2: ageDays, sex: Sex.Female, z: ref z))
            {
                double p = StatisticsHelper.CalculatePercentile(z);

                z = Math.Round(z, 2);
                p = Math.Round(p, 2);

                Console.WriteLine($"[WHO 2006] - {ageDays} day old female with BMI = {bmi} has z-score of {z} and percentile of {p}");
            }
            else
            {
                Console.WriteLine($"{ageMonths} is a valid age in days for the WHO 2006 BMI-for-age indicator.");
            }

            // Calculates a BMI-for-age z-score using WHO 2007
            ageMonths = 64;
            bmi       = 17;

            if (who2007.TryCalculateZScore(indicator: Indicator.BodyMassIndexForAge, measurement: bmi, age: ageMonths, sex: Sex.Female, z: ref z))
            {
                double p = StatisticsHelper.CalculatePercentile(z);

                z = Math.Round(z, 2);
                p = Math.Round(p, 2);

                Console.WriteLine($"[WHO 2007] - {ageMonths} month old male with BMI = {bmi} has z-score of {z} and percentile of {p}");
            }
            else
            {
                Console.WriteLine($"{ageMonths} is a valid age in months for the WHO 2007 BMI-for-age indicator.");
            }

            Console.WriteLine();

            // If interested in performance tests, see below
            TestCDC2000ComputeSpeed(true);  // forces test to use interpolation of L, M, and S values (more computationally expensive)
            TestCDC2000ComputeSpeed(false); // forces test to never use interpolation

            Console.WriteLine();

            TestWHO2006ComputeSpeed(); // WHO 2006 standard doesn't typically need interpolation since age is measured in days, and trying to interpolate LMS values between e.g. day 66 and 67 is not worthwhile

            Console.WriteLine();

            TestWHO2007ComputeSpeed(true);  // forces test to use interpolation of L, M, and S values (more computationally expensive)
            TestWHO2007ComputeSpeed(false); // forces test to never use interpolation
        }