This project is read-only.

Using SmartStats with C#

1) Type https://smartstats.codeplex.com in your browser address bar. SmartStats home page will open as shown in figure below. Click the Download Button.

DownloadSmartStat.jpg

2) SmartStats.dll will be downloaded in your system. Save it at some convenient location.

3) Open Visual Studio and create new C# console application. Name it TestSmartStats and click Ok.
createproject.bmp

4) In the project solution explorer right click References and select Add Reference. Reference Manager Window will open. Click Browse and give path for SmartStats.dll . Click OK.
addreference.bmp

5) Now you are set to use functions of SmartStats. Following demo code can be used for reference in your console program:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SmartStats;  //Add reference of SmartStats

namespace TestSmartStats
{
    class Program
    {
        static void Main(string[] args)
        {
            
            //Demo For some of the Central Tendancy Calculations
            Double[] testInput1 = new Double[11] { 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55 };
            SmartStats.centralTendency statOpsCT = new SmartStats.centralTendency();
            Double average = statOpsCT.mean(testInput1); //calculate average
            Double median = statOpsCT.median(testInput1); //calculate median
            Double mode = statOpsCT.mode(testInput1); //calculate mode
            Console.WriteLine("Average= " + average);
            Console.WriteLine("Median = " + median);
            Console.WriteLine("Mode= " + mode);

            //Demo For some of the correlation Calculations
            Double[] testInput2 = new Double[11] {1, 2, 3, 5, 8, 13, 21, 34, 55 ,89,144};
            SmartStats.correlation statOpsCorr = new SmartStats.correlation();
            Double cov = statOpsCorr.covariance(testInput1, testInput2); //calculate covariance
            Double pearsonCorr = statOpsCorr.PearsonCorrelation(testInput1, testInput2); //calculate pearson correlation coefficient
            Console.WriteLine("Covariance= " + cov);
            Console.WriteLine("PearsonCorrelation = " + pearsonCorr);

            //Demo For some of the Dispersion Calculations
            SmartStats.dispersion statOpsDis = new SmartStats.dispersion();
            Double std = statOpsDis.StdDev(testInput1); //calculate standard deviation
            Double sig2noise = statOpsDis.Signal2NoiseRatio(testInput1); //calculate signal to noise ratio
            Double kurto = statOpsDis.kurtosis(testInput1);//calculate kurtosis
            Console.WriteLine("Standard Deviation= " + std);
            Console.WriteLine("Signal To Noise Ratio = " + sig2noise);
            Console.WriteLine("Kurtosis = " + kurto);

            //Demo For some of the regression analysis
            Double[] testX_SLR = new Double[5] {1,2,3,4,5}; //X-Value for simple linear regression
            Double[] testY_SLR = new Double[5] {6,9,15,18,23}; //Y-Value for simple linear regression
            SmartStats.Regression statOpsReg = new SmartStats.Regression();
            //Simple Linear regression fits equation in terms of y=aX+b; inputs are x and y and result is a and b.
            Double[] SLR = statOpsReg.SimpleLinearRegression(testX_SLR, testY_SLR); 
            Console.WriteLine("Equation Generated form Simple Linear regression= y={0}X + {1}",SLR[0],SLR[1]);


            //Demo For some of the matrix operations
            Double[,] testXinv = new Double[3,3] { {3,4,6}, {2, 3, 4}, {5,3,2} }; //input matrix for matrix inversion
            SmartStats.MatrixOperations statOpsMat = new SmartStats.MatrixOperations();
            Double[,] InvertedMat = statOpsMat.matrixInvert(testXinv); //invert matrix
            Console.WriteLine("Inverted Matrix=");
            for(int i=0;i<InvertedMat.GetLength(0);i++)
            { 
                for(int j=0;j<InvertedMat.GetLength(1);j++)
                {
                    Console.Write(InvertedMat[i,j] + "  ");
                }
                Console.Write("\n");
            }
            Console.ReadLine();    
        }
    }
}

Last edited Sep 8, 2013 at 12:40 PM by panthimanshu17, version 15