Spread Deviation 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 spread
/// and deviation statistics on a data sheet (e.g. variance and
/// standard deviation).
/// </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 spread and deviation statistics for
// the math result column.
Console.WriteLine("Coefficient of variation: {0}",
calculator.CoefficientOfVariation("MathResult"));
Console.WriteLine("Mean deviation: {0}",
calculator.MeanDeviation("MathResult"));
Console.WriteLine("Median deviation: {0}",
calculator.MedianDeviation("MathResult"));
Console.WriteLine("Root mean square: {0}",
calculator.RootMeanSquare("MathResult"));
Console.WriteLine("Variance: {0}",
calculator.Variance("MathResult"));
Console.WriteLine("Standard deviation: {0}",
calculator.StandardDeviation("MathResult"));
Console.WriteLine("Standard error: {0}",
calculator.StandardError("MathResult"));
Console.WriteLine("Sum square deviation: {0}",
calculator.SumSquareDeviation("MathResult"));
Console.WriteLine();
}
}
}