Statsar Statistics Library

v1.0.1 for .NET

Product Guide



More Information...

Valid XHTML


Central Moments Example (C#)

[C#]
/* COPYRIGHT(C), SIMPLEXAR SOFTWARE LIMITED, 2006-2008.
 * All rights reserved.
 *
 * Use of this copyright notice is precautionary only, and does not imply
 * publication or disclosure. The content of this work contains confidential
 * and proprietary information of Simplexar Software Limited. Any duplication,
 * modification, distribution, or disclosure in any form, in whole, or in part,
 * is strictly prohibited without express prior written permission.
 */

// Get namespaces.
using System;
using Simplexar.Statsar;

// Start namespace.
namespace Simplexar.Examples.Statsar
{
    /// <summary>
    /// This example uses the statistics calculator to perform central moment
    /// statistics on a data sheet (e.g. skew and kurtosis).
    /// </summary>
    public static class Example
    {
        /// <summary>
        /// The application entry point.
        /// </summary>
        public static void Main()
        {
            try
            {
                RunExample();
            }
            catch(Exception exception)
            {
                Console.WriteLine(exception);
            }
            Console.WriteLine("Press ENTER to terminate.");
            Console.ReadLine();
        }

        private static void RunExample()
        {
            // Create a calculator.
            StatsCalculator calculator = new StatsCalculator();
                       
            // Use the calculator to load the sheet.
            DataSheet sheet = calculator.Load(
                @"..\..\..\..\..\Data\ExamResults.csv");
            Console.WriteLine(sheet);

            // Calculate central moment statistics for
            // the math result column.
            Console.WriteLine("Skew: {0}",
                calculator.Skew("MathResult"));

            Console.WriteLine("Kurtosis: {0}",
                calculator.Kurtosis("MathResult"));

            Console.WriteLine("5th standard moment: {0}",
                calculator.StandardMoment("MathResult", 5));

            Console.WriteLine("6th central moment: {0}",
                calculator.CentralMoment("MathResult", 6));
        }
    }
}