Statistical Formulas in Windows Forms Chart

1 Dec 202224 minutes to read

Essential Chart comes with support for several Statistical formulas that will let you apply formulas on data points in one or more series and will help you analyze and arrive at meaningful information from those data points.

These formulas are mainly exposed via static methods from the BasicStatisticalFormulas and UtilityFunctions types.

Basic Statistical Formulas

Some commonly used statistical formulas that you can apply on the series points are exposed via static methods in the BasicStatisticalFormulas type.

BasicStatisticalFormula

Statistical Formulas Description

ANOVA

An ANOVA test is used to test the differences between the means of two or more groups of data.

Correlation

The Correlation formula shows how strong the relation is between two random variables.

Covariance

The Covariance formula measures the degree of dependence between two random variables.

F-Test

An F-test is any statistical test in which, the test statistic has an F-distribution if the null hypothesis is true.

Mean

This formula returns the average, or mean, of data stored in a data series.

Median

This formula returns the median for data stored in a data series.

StandardDeviation

This formula returns the Standard Deviation within a group of data.

T Test with Equal Variances

Perform a T Test using Student's distribution (T distribution) with equal variances.

T Test Paired

Performs a T Test using Student's distribution (T distribution) with paired samples. This is useful when there is a natural pairing of observations in samples. (i.e. when a sample group is tested twice.)

T Test with unequal variances

Perform a T Test using Student's distribution (T distribution) with unequal variances.

Variance

This formula returns the variance within a group of data.

ZTest

This formula performs a Z Test using Normal distribution.

ANOVA Test

ANOVA stands for Analysis Of Variance. It is a technique to test the hypothesis that means among two or more groups of data are equal and thereby, testing the differences between their variances, under the assumption that the sampled groups are normally distributed.

The test actually compares the variation between the groups with the variation within the groups and produces the results based on the values of these variations. If the between variation is larger than the within variation, the means of the groups will not be equal. If both these variations are of approximately the same size, then there will not be any significant difference between the means.

Steps to perform an ANOVA test

The null hypothesis is that there is no difference between the means and the alternative hypothesis is that at least one means is different.

The following assumptions must be satisfied before performing the test.

  • The groups from which the samples were obtained must be normally distributed.
  • The groups are sampled randomly.
  • The samples must be independent.
  • The variances of the groups must be equal.
  • The null hypothesis.
  1. Calculate the Sum of Squares for total, between and within variations.

    Total Variation

    Chart Formulas

    Between Variation

    Chart Formulas

    Where,

    y is the individual y point of the series,

    r is the number of series present,

    N is the total number of y points for all the series and

    n is the number of y points in each series.

    Within Variation

    SSwithin = SStotal - SSamong

  2. Using the above quantities, calculate the degrees of freedom(df) for these variations.

    Between Variation

    dfamong = r-1

    Within Variation

    dfwithin = N-r

    Where,

    r is the number of series present and

    N is the total number of Y points for all the series.

  3. As the next step, calculate the Mean Squares of these variations. The mean square for a variation can be calculated simply by dividing its sum of square by its degrees of freedom.

    Between Variation

    Chart Formulas

    Within Variation

    Chart Formulas

  4. Finally, calculate F Ratio as below and get the F Critical Value.

    Chart Formulas

  5. Make your decision as below.

    • If the between variance is smaller than the within variance, then the means are really close to each other and you will fail to reject the null hypothesis.
    • If the F ratio is greater than the F critical value, then the decision will be to reject the null hypothesis and thereby conclude that at least one of the means is different.

APIs Used

EssentialChart provides support to perform ANOVA Test by implementing a method named Anova in the BasicStatisticalFormulas class. This method does the above described calculations and returns the test results as an instance of AnovaResult class. The AnovaResult is a class implemented to store the ANOVA test results such as sum of squares, degrees of freedom and mean squares for different variations and also stores the FRatio and FCriticalValue of the test. Below is a detailed table for the ANOVA method.

Methods

Method Name Parameters Return Values
Anova
  • Probability: the alpha value (probability).
  • InputSeries: references to two or more input series. Each series must exist in the series collection at the time of the method call, and have the same number of data points.
An Anova has the following members:
  • DegreeOfFreedomBetweenGroups
  • DegreeOfFreedomTotal
  • DegreeOfFreedomWithinGroups
  • FCriticalValue
  • FRatio
  • MeanSquareVarianceBetweenGroups
  • MeanSquareVarianceWithinGroups
  • SumOfSquaresBetweenGroups
  • SumOfSquaresTotal
  • SumOfSquaresWithinGroups

Here is a sample code snippet to simulate an ANOVA test.

AnovaResult ar = BasicStatisticalFormulas.Anova(confidenceLevel,new ChartSeries[]{ series1, series2, series3} );
Dim ar As AnovaResult = BasicStatisticalFormulas.Anova(confidenceLevel, New ChartSeries(){ series1, series2, series3})

The following image displays the results of an ANOVA test.

Chart Formulas

Correlation

Correlation, which is otherwise called as Correlation Coefficient, is a statistical formula that determines the degree of relationship between the y values of two series representing two variables. This calculation will then be used to measure the depth of synchronization between those two variables.

A relationship generally refers to the correspondence between two variables. For instance, let us have two variables with one representing Work Experience while the other indicating the Salary Expectation. If the Work Experience is high, then the Salary Expectation will also be high. When Work Experience is low, then the Salary Expectation also tends to be low. Thereby these two variables are correlated.

The relationships can be classified into two types, Positive and Negative. In a positive relationship, high values on one variable are associated with high values on the other and low values on one variable are associated with low values on the other. The negative relationship is just the inverse of the positive relationship where the high values on one variable are associated with low values on the other.

When the measured correlation coefficient is positive, the series values would be positively correlated whereas if the correlation coefficient is negative, then the series values would then be negatively correlated. Below is the formula for calculating correlation coefficient.

Chart Formulas

where,

x is the y value of first series and

y is the y value of second series.

Using the Formula

The Correlation Coefficient can easily be calculated by using the Correlation method available with the BasicStatisticalFormulas class. The following table describes the details of this method. This method returns the covariance of the datasets divided by the product of their standard deviations.

Methods

Method Name Parameters Return Value

Correlation

  • FirstInputSeries: A ChartSeries object that stores the first group's data.
  • SecondInputSeries: A ChartSeries object that stores the second group's data. An exception will be raised if the input series does not have the same number of data points.
A double that represents the correlation value between the two groups of data. The value always ranges from -1 to 1.

Example

The below code snippet demonstrates how to get the correlation coefficient between two groups of data (Series1 and Series2) using the in-built formula.

using Syncfusion.Windows.Forms.Chart.Statistics;

............

double Correlation1= BasicStatisticalFormulas.Correlation(series1,series2);
Imports Syncfusion.Windows.Forms.Chart.Statistics

.............

Dim Correlation1 As Double

Correlation1=BasicStatisticalFormulas.Correlation(series,series1)

NOTE

For further details, refer to this Browser Sample:

<Install Location>\Syncfusion\EssentialStudio<Install version>\Windows\Chart.Windows\Samples\Statistical Analysis\Chart Statistical Formulas

Covariance

Covariance is a statistical formula that measures the extent to which the y values of two series vary together. It is basically used to measure the fluctuations between two quantities. For a given pairs of series y values, the covariance can be calculated by taking their differences from their mean values and multiplying these differences together. That is,

Cov(x,y) = {[ x-(x) ][ y-(y) ]}

If this product is positive, then the values would be varying in the same direction; if it is negative, then the values would be varying in opposite directions. If the product is zero, then we can conclude that there is no linear relationship between the series values. The above formula can be simplified as below.

Cov(x,y) = {xy} - {x}{y}

Using the Formula

The Covariance can easily be calculated by using the Covariance method available with the BasicStatisticalFormulas class. The following table describes the details of this method.

Methods

Method Name Parameters Return Value

Covariance

  • FirstInputSeriesName: A ChartSeries object that stores the first group's data.
  • SecondInputSeriesName: A ChartSeries object that stores the second group's data. An exception will be raised if the input series do not have the same number of data points.
A double value that represents the covariance value between the two groups of data.

Example

Here is the code snippet that demonstrates the usage of this method.

using Syncfusion.Windows.Forms.Chart.Statistics;

............

double Covariance1= Statistics.BasicStatisticalFormulas.Covariance(series1,series2);
Imports Syncfusion.Windows.Forms.Chart.Statistics

.............

Dim Covariance1 As Double

Covariance1=BasicStatisticalFormulas.Covariance (series,series1)

NOTE

For further details, refer to this Browser Sample:

<Install Location>\Syncfusion\EssentialStudio<Install version>\Windows\Chart.Windows\Samples\Statistical Analysis\Chart Statistical Formulas

F-Test

The F-Test is a statistical test, which is carried out to find out whether two series have the same standard deviation with the specified confidence level. It is achieved by comparing the variances of the series values and thereby comparing their standard deviations. Here, the null hypothesis is that the two variances are equal. All hypothesis testing is done under the assumption that the null hypothesis is true.

Steps to perform F-Test

  1. Calculate the variances of both the series.
  2. Calculate F Ratio as given below.

F Value_ _= firstSeriesVariance / secondSeriesVariance.

F-Test can be easily performed by using the FTest method of BasicStatisticalFormulas class that returns the results as a type of FTestResult. The FTestResult is a class implemented to save the F test result as FValue and other computation results such as series means, series variances, FRatio and FCriticalValue of the test. Below is a detailed table for the FTest method.

Methods

Method Name Parameters Returns
FTest
  • Probability: Probability that gives the confidence level.
  • FirstInputSeries: Type of ChartSeries object that represents the first group of data.
  • SecondInputSeries: Type of ChartSeries object that represents the second group of data.
An FTestResult has the following members:
  • FirstSeriesMean
  • SecondSeriesMean
  • FirstSeriesVariance
  • SecondSeriesVariance
  • FValue
  • ProbabilityFOneTail
  • FCriticalValueOneTail

Example

Here is a code snippet that shows a sample usage.

FTestResult result = Syncfusion.Windows.Forms.Chart.Statistics.BasicStatisticalFormulas.FTest(confidenceLevel,series1,series2);
Dim result As FTestResult = Syncfusion.Windows.Forms.Chart.Statistics.BasicStatisticalFormulas.FTest(confidenceLevel,series1,series2)

NOTE

For further details, refer to this Browser Sample:

<Install Location>\Syncfusion\EssentialStudio<Install version>\Windows\Chart.Windows\Samples\Statistical Analysis\Chart Statistical Formulas

Mean

Mean is statistical formula that returns the arithmetic average of series y values where the arithmetic average is the sum of all y values of a series divided by the total number of y values present in that series. The arithmetic mean can be calculated for any chart series by using Mean method of the BasicStatisticalFormulas class. Below table shows the method details.

Methods

Method Name Parameter Return value

Mean

InputSeries: A ChartSeries type object for whose y values an average is required. A double that represents the average of all the y values in the given series.

Example

Here is a code snippet that shows a sample usage.

using Syncfusion.Windows.Forms.Chart.Statistics;

............

double calculatedMean = BasicStatisticalFormulas.Mean(series1);
Imports Syncfusion.Windows.Forms.Chart.Statistics

.............

Dim calculatedMean As Double

calculatedMean = BasicStatisticalFormulas.Mean(series1)

NOTE

For further details, refer to this Browser Sample:

<Install Location>\Syncfusion\EssentialStudio<Install version>\Windows\Chart.Windows\Samples\Statistical Analysis\Chart Statistical Formulas

Median

Median is a statistical formula that is used to find the median of y values of a series. Median can be calculated by arranging the values from the lowest to the highest and picking up the middle one. If the total number of values is even, then pick up the two middle values after sorting the values in ascending order. The mean of these two middle values will give you the median. Hence half of the series points have values less than the median and the values of the other half will be greater than the median.

Median can be found out for any series by using the Median method of BasicStatisticalFormulas class. The below table shows the details of this method.

Methods

Method Name Parameter Return value

Median

InputSeries: A ChartSeries type object for whose X values an average is required. A double that represents the Median value of all the X values in the given series.

Example

Here is a code snippet that shows a sample usage.

using Syncfusion.Windows.Forms.Chart.Statistics;

............

double calculatedMedian = Statistics.BasicStatisticalFormulas.Median(series1);
Imports Syncfusion.Windows.Forms.Chart.Statistics

.............

Dim Median1 As Double

calculatedMedian = BasicStatisticalFormulas.Median(series1)

NOTE

For further details, refer to this Browser Sample:

<Install Location>\Syncfusion\EssentialStudio<Install version>\Windows\Chart.Windows\Samples\Statistical Analysis\Chart Statistical Formulas

Standard Deviation

StandardDeviation is the statistical formula that is basically used to measure the variability. That is, it can be used to measure how to spread out your data are. It can be defined as the square root of the variance where a variance is the average of the squared differences between the data points and the mean. In other words, it is named as the root-mean-square of the data values.

It can be used to check how tightly the data values are clustered around the mean. If the data points are close to the mean, then the standard deviation will be small or if the points are far from the mean, then the standard deviation is large or if all the data values are equal, then the standard deviation is zero.

The Standard Deviation can be calculated for any series by using the StandardDeviation method of BasicStatisticalFormulas class. Below is the detailed description of this method.

Methods

Method Name Parameters Return Value

StandardDeviation

  • InputSeries: A ChartSeries type object for on whose Y values this formula should be applied.
  • SampleVariance: true if the data is a sample of a population, false if it is the entire population.
A double that represents the standard deviation within the group of data.

Example

Here is a code snippet that shows a sample usage.

using Syncfusion.Windows.Forms.Chart.Statistics;

............

double Deviation1 = BasicStatisticalFormulas.StandartDeviation(series1,false);
Imports Syncfusion.Windows.Forms.Chart.Statistics

.............

Dim Deviation1 As Double

Deviation1 = BasicStatisticalFormulas. StandartDeviation  (series1,false)

NOTE

For further details, refer to this Browser Sample:

<Install Location>\Syncfusion\EssentialStudio<Install version>\Windows\Chart.Windows\Samples\Statistical Analysis\Chart Statistical Formulas

T-Tests

T-Test is a statistical formula that is used to measure the equality between the means of two series. In other words, the T-test compares the actual difference between two means in relation to the variation in data that can be measured by calculating the standard deviation of the difference between the means.

It is a statistical test used to test the null hypothesis that the means of two normally distributed populations are equal. This test can be performed on two given samples (series), each characterized by its mean, standard deviation and number of data points, to determine whether the means are distinct based on the assumption that the underlying distributions are normal.

Different T-Tests

There are different versions of T tests depending on whether the samples are:

  • Independent of each other, (where the series are random with no relationship between each other)

    OR

  • Paired, (where every data point in one series will have a relationship with a particular point of another series).

If the calculated t-statistic exceeds the chosen threshold value (usually 0.05), then the decision is to reject the null hypothesis, which states that the two sample means are equal, in favor of an alternate hypothesis, which typically specifies that the two samples differ.

Below are the different formulae to calculate the t-statistic:

  • T-Test with Equal Variances

This formula performs a T test for two groups of data and assumes equal variances between the two groups (i.e. series).

  • T-Test Paired

This formula performs a paired two-sample student’s t-test to determine whether a sample’s means are distinct. This form of the t-test does not assume that the variances of both the populations are equal.

Use a paired test when there is a natural pairing of observations in the samples, such as a sample group that is tested twice. (e.g. before and after an experiment)

  • T-Test with UnEqual Variances

This formula performs a T-test for two groups of data and assumes unequal variances between the two groups. (i.e. series)

This analysis tool is referred to as a heteroscedasticity t-test and can be used when the groups that are under study are distinct. Use a paired test when there is one group before and after a treatment.

NOTE

For programming example, refer to the following Browser Sample:

<Install Location>\Syncfusion\EssentialStudio<Install version>\Windows\Chart.Windows\Samples\Statistical Analysis\Chart Statistical Formulas

TTest with Equal Variances

This type of TTest can be performed on two random series that have no relationship with each other. But they should be of equal sizes, i.e., the number of data points of the two series should be same.

Steps to perform the test

  1. Specify the null hypothesis and alternate hypothesis.

    • Null Hypothesis - Difference between the two means is zero.
    • Alternate Hypothesis - Difference between the two means is not zero.
  2. Calculate the means of the two input series (µ1 and µ2)and calculate their difference (Md).

    Md = µ1 - µ2

  3. Calculate the variances of the two input series (s1 and s2).

  4. Let n1 and n2 be the number of data points in first and second series respectively.

  5. Calculate the degrees of freedom.

    D = n1 + n2 - 2

  6. As a next step, calculate the Pooled Estimator as below.

    Sp = (n1 - 1) * s1 + (n2 - 1) * s2

  7. Calculate the T-statistic as given below.

    t = (µ1 - µ2 - Md) / Sqrt(Sp/n1 + Sp/n2)

  8. Construct a t-table at (n1+n2-2) degrees of freedom.

  9. Choose a level of significance(probability), say p = 0.05 and read the tabulated value.

  10. If the calculated tvalue exceeds the tabulated value we can say that the means are significantly different at that level of probability.

Using the Formula

The TTest formula for equal variances can be calculated by using the TTestEqualVariances method of the BasicStatisticalFormulas class. The following table presents the details of this method. This method returns an instance of TTestResult class that stores the resultant values of this test such as means of the two series, T value, degrees of freedom, number of points in every series, T critical value and confidence level(probability).

Methods

Method Name Parameters Return Value

TTestEqualVariances

  • HypothesizedMeanDifference: A double value specifying the difference between two population means.
  • Probability: A double value that gives the confidence level.
  • FirstInputSeries: A ChartSeries object that stores the first group of data.
  • SecondInputSeries: A ChartSeries object that stores the second group of data.
A TTestResult object that has the following members:
  • FirstSeriesMean
  • SecondSeriesMean
  • FirstSeriesVariance
  • SecondSeriesVariance
  • Tvalue
  • DegreeOfFreedom
  • ProbabilityTOneTail
  • TCriticalValueOneTail
  • ProbabilityTTwoTail
  • TCriticalValueTwoTail

Example

Here is a code snippet that shows a sample usage.

using Syncfusion.Windows.Forms.Chart.Statistics;

TTestResult result = BasicStatisticalFormulas.TTestEqualVariances (0.2, 0.05, series1, series2);
Imports Syncfusion.Windows.Forms.Chart.Statistics

Dim result As TTestResult = BasicStatisticalFormulas.TTestEqualVariances (0.2, 0.05, series1, series2)

T-Test with UnEqual Variance

If the assumption of ‘equal variances’ is violated, then we have to compute the test statistic using the individual sample’s standard deviation instead of pooled standard deviation. Like the TTestEqualVariances formula, the TTestUnequalVariances formula also will be carried out on two independent samples. The only difference with unequal variances test is that the sample should be of different sizes.

Steps to perform the test

1.Specify the null hypothesis and alternate hypothesis.

  • Null Hypothesis - Difference between the two means is zero.
  • Alternate Hypothesis - Difference between the two means is not zero.

2.Calculate the means of the two input series (µ1 and µ2)and calculate their difference (Md).

Md = µ1 - µ2

3.Calculate the variances of the two input series (s1 and s2).

4.Let n1 and n2 be the number of data points in first and second series respectively.

5.Calculate the degrees of freedom.

Chart Formulas

6.Calculate the T-statistic as given below.

t = (µ1 - µ2 - Md) / Sqrt( s1/n1 + s2/n2 )

7.Choose a level of significance (probability), say p = 0.05 and read the tabulated value.

8.If the calculated tvalue exceeds the tabulated value we can say that the means are significantly different at that level of probability.

Using the Formula

The TTest formula for unequal variances can be calculated by using the TTestUnEqualVariances method of the BasicStatisticalFormulas class. The following table presents the details of this method. This method returns an instance of TTestResult class that stores the resultant values of this test such as means of the two series, T value, degrees of freedom, number of points in every series, T critical value and confidence level (probability).

Methods

Method Name Parameters Return Value

TTestUnEqualVariances

  • HypothesizedMeanDifference: A double value that gives the difference between the means of the two input series.
  • Probability: A double value that denotes the probability that gives the confidence level.
  • FirstSeries: A ChartSeries object that stores the first group of data.
  • SecondSeries: A ChartSeries object that stores the second group of data.
A TTestResult object that has the following members:
  • FirstSeriesMean
  • SecondSeriesMean
  • FirstSeriesVariance
  • SecondSeriesVariance
  • Tvalue
  • DegreeOfFreedom
  • ProbabilityTOneTail
  • TCriticalValueOneTail
  • ProbabilityTTwoTail
  • TCriticalValueTwoTail

Example

Here is a code snippet that shows a sample usage.

TTestResult result = BasicStatisticalFormulas.TTestUnEqualVariances(0.2, 0.05,series1,series2);
Dim result As TTestResult = BasicStatisticalFormulas.TTestUnEqualVariances(0.2, 0.05, series1, series2)

TTest Paired

This formula is used when there is a dependency between the samples. The two possible scenarios could be when there is a single sample that is tested twice (before and after an experiment), or when there are two samples whose values can be matched. This test assumes that there is some difference between the means of two input series populations. Input series are regarded as samples from normally distributed populations. The population variances are assumed to be unequal. This test is otherwise called as Robust TTest.

Steps to perform the test

1.Specify the null hypothesis and alternate hypothesis.

  • Null Hypothesis: Difference between the two means is zero.
  • Alternate Hypothesis: Difference between the two means is not zero.

2.Calculate the difference between two series on each pair of values. Calculate the mean difference ( Mdiff ), i.e. mean of the new series values.

3.Calculate the Standard Deviation of the differences( SD ).

4.Get the degrees of freedom.

Chart Formulas

5.Compute the t-statistic as given below.

t = ( Mdiff - Md ) / [SD * Sqrt( 1/n1 )]

6.Construct a t-table at (n1 - 1) degrees of freedom and get the tabulated value for a given level of significance (probability).

7.If the calculated tvalue exceeds the tabulated value we can say that the means are significantly different at that level of probability.

Using the Formula

The TTest formula for dependent samples can be calculated by using the TTestPaired method of the BasicStatisticalFormulas class. The following table presents the details of this method. This method returns an instance of TTestResult class that stores the resultant values of this test such as means of the two series, T value, degrees of freedom, and number of points in every series, T critical value and confidence level (probability).

Methods

Method Name Parameters Return Value

TTestPaired

  • HypothesizedMeanDifference: A double value specifying the difference between two population means.
  • Probability: A double value that denotes the probability that gives the confidence level.
  • FirstSeries: A ChartSeries object that stores the first group of data.
  • SecondSeries: A ChartSeries object that stores the second group of data.
A TTestResult object that has the following members:
  • FirstSeriesMean
  • SecondSeriesMean
  • FirstSeriesVariance
  • SecondSeriesVariance
  • Tvalue
  • DegreeOfFreedom
  • ProbabilityTOneTail
  • TCriticalValueOneTail
  • ProbabilityTTwoTail
  • TCriticalValueTwoTail

Example

Here is a code snippet that shows a sample usage.

using Syncfusion.Windows.Forms.Chart.Statistics;

TTestResult result = BasicStatisticalFormulas.TTestPaired(0.2, 0.05, series1, series2);
Imports Syncfusion.Windows.Forms.Chart.Statistics

Dim result As TTestResult = BasicStatisticalFormulas.TTestPaired(0.2, 0.05, series1, series2)

Variance

Variance is a statistical formula that calculates the variance of series y values. A Variance can be defined as the square of the standard deviation of a sample.

Using the Formula

The variance can be computed for any series by using the method Variance of BasicStatisticalFormulas class. Below table shows the details of this method.

Methods

Method Name Parameters Return Value

Variance

  • InputSeries: A ChartSeries object that represents the input series.
  • SampleVariance: A boolean value; true if the data is a sample of a population, false if it is the entire population.
A double that represents the variance within the group of data.

Example

Variance is the square of the standard deviation for the given data.

using Syncfusion.Windows.Forms.Chart.Statistics;

............

double Variance1= BasicStatisticalFormulas.Variance(series1,false);
Imports Syncfusion.Windows.Forms.Chart.Statistics

.............

Dim Variance1 As Double
Variance1=BasicStatisticalFormulas.Variance (series1,false)

Z-Test

Z-test is a statistical formula that is used to determine if the difference between a sample mean and the population mean is large enough to be statistically significant. This test is primarily used to determine if the test scores of the samples are either within or outside the standard scores.

Steps to perform ZTest

This test requires the sample to be random and is taken from a population that is distributed normally. In order to perform this test, the following quantities should be known.

  • s (the standard deviation of the population)
  • µ (the mean of the population)
  • x (the mean of the sample)
  • n (the size of the sample)

1.Calculate the standard error (SE) of the mean:

Chart Formulas

2.Then compute the z-score for the Z-test as below.

Chart Formulas

3.Finally, the z score is compared to a Z table which contains the percent of area under the normal curve between the mean and the z score. Using this table will indicate whether the calculated z score is within the realm of chance or it is so different from the mean that the sample mean is unlikely to have happened by chance.

Using the Formula

The Z-test can be carried out on any two series values by using the ZTest method of BasicStatisticalFormulas class. Below table gives the detailed description of this method. The method returns an instance of ZTestResult object that saves the intermediate results and also the final z score of the test.

Methods

Method Name Parameters Return Value

ZTest

  • HypothesizedMeanDifference: the difference between the population means.
  • VarianceOfFirstSeries: the variance within the first series population.
  • VarianceOfSecondSeries: the variance within the second series population.
  • Probability: the probability that gives the confidence level.
  • FirstSeries: A ChartSeries object that stores the first group of data.
  • SecondSeries: A ChartSeries object that stores the second group of data.
An ZTestResult object that has the following members:
  • FirstSeriesMean
  • SecondSeriesMean
  • FirstSeriesVariance
  • SecondSeriesVariance
  • ZValue
  • ProbabilityZOneTail
  • ZCriticalValueOneTail
  • ProbabilityZTwoTail
  • ZCriticalValueTwoTail

Example

Here is a code snippet that shows a sample usage.

ZTestResult result = BasicStatisticalFormulas.ZTest( Convert.ToDouble(TextBox6.Text.ToString()), 

sqrtVarianceOfFirstSeries*sqrtVarianceOfFirstSeries,

sqrtVarianceOfSecondSeries* sqrtVarianceOfSecondSeries,0.05,series1,series2);
Dim result As ZTestResult = BasicStatisticalFormulas.ZTest(Convert.ToDouble(TextBox6.Text.ToString()), sqrtVarianceOfFirstSeries*sqrtVarianceOfFirstSeries, sqrtVarianceOfSecondSeries*sqrtVarianceOfSecondSeries, 0.05, series1, series2)

NOTE

For programming example, refer to the following Sample:

<Install Location>\Syncfusion\EssentialStudio<Install version>\Windows\Chart.Windows\Samples\Statistical Analysis\Chart Statistical Formulas

Utility Functions

Listed below are some common statistical formulas that are implemented in the Utilities type.

Utilities

Statistical Formulas Description

Beta Function

The BetaFunction method returns the beta function for a given value.

Beta Cumulative Distribution

The Beta Cumulative Distribution method returns the Beta cumulative distribution for a given value.

Inverse Beta Cumulative Distribution

The Inverse Beta Cumulative Distribution method returns the Inverse Beta cumulative distribution for a given value.

Gamma Function

The GammaFunction method returns the gamma function for a given value.

Gamma Cumulative Distribution

The Gamma Cumulative Distribution method returns the Gamma cumulative distribution for a given value.

FCumulative Distribution

The F Cumulative Distribution method returns the FCumulative distribution for a given value.

Inverse FCumulative Distribution

The Inverse F Cumulative Distribution method returns the Inverse F Cumulative distribution for a given value.

TCumulative Distribution

The T Cumulative Distribution method returns the T Cumulative distribution for a given value.

Inverse TCumulative Distribution

The Inverse T Cumulative Distribution method returns the Inverse T Cumulative distribution for a given value.

Normal Distribution

The Normal Distribution method returns the Normal distribution for a given value.

Inverse Normal Distribution

Returns the inverse of the standard normal cumulative distribution. The distribution has a mean of 0 (zero) and a standard deviation of one.

Normal Distribution Density

The Normal Distribution Density method returns the Normal distribution density for a given value.

Binomial

The Binomial method returns the Binomial coefficient for a given Value.

Factorial

The Factorial method returns the Factorial for a given Value.(eg 2!=2).

Error Function

The Erf method returns the Error Function for a given Value.

Inverse Error Function

The Inverse Erf method returns the Inverse Error Function for a given Value.

Beta Function

There are two widely used utility functions, the Gamma and Beta functions, which are used in statistics to calculate distribution values. These functions always return a double value and use two double values for input. The beta function was studied by Euler and Legendre and was named by Jacques Binet. In mathematics, the beta function (occasionally written as Beta function) which, is also called the Euler integral of the first kind, is a special function defined by:

Chart Formulas

where G(x) is the gamma function.

Using the Formula

The Beta method of the UtilityFunctions class calculates the beta function for given two values.

Methods

Method Name Parameters Return Value

Beta

  • a: The first value.
  • b: The second value.
A double that represents the beta function value.

Example

Here is a code snippet that shows a sample usage.

using Syncfusion.Windows.Forms.Chart.Statistics;

double result = UtilityFunctions.Beta(a,b);
Imports Syncfusion.Windows.Forms.Chart.Statistics

Dim double as result = UtilityFunctions.Beta(a,b);

Beta Cumulative Distribution

The Beta Distribution can be defined as a family of probability distributions differing in the values of α and β. The Cumulative distribution function is given below.

Chart Formulas

where Bx(α, ß) is the incomplete beta function and Ix(α, ß) is the regularized incomplete beta function.

Using the Formula

The BetaCumulativeDistribution method of the UtilityFunctions class returns the cumulative beta distribution for x>=0, a >0, b>0.

Methods

Method Name Parameters Return Value

BetaCumulativeDistribution

  • a: The lower limit.
  • b: The upper limit.
  • x: the value for which the distribution has to be calculated.
A double that represents the cumulative beta distribution.

Example

Here is a code snippet that shows a sample usage.

ChartSeries series = new ChartSeries("a=b=0.5");

for(double i = 0; i <= 1; i = i + 0.1)

{

// Calculate Beta cumulative function for a points and plot the points in chart control.

series.Points.Add(i,Syncfusion.Windows.Forms.Chart.Statistics.UtilityFunctions.BetaCumulativeDistribution(0.5,0.5,i));

}

series.Type = ChartSeriesType.Spline;

series.Tex = series.Name;

this.ChartControl1.Series.Add(series);
'Calculate Beta cumulative function for a points and plot the points in chart control.

Dim series As New ChartSeries("a=b=0.5")

For i As Double = 0 To 1 Step 0.1

series.Points.Add(i,Syncfusion.Windows.Forms.Chart.Statistics.UtilityFunctions.BetaCumulativeDistribution(0.5,0.5,i))

Next i

series.Type = ChartSeriesType.Spline

series.Text = series.Name

Me.ChartControl1.Series.Add(series)

Binomial Coefficient

Binomial Coefficient is an utility function used in statistical calculations. This function is used to determine the possible number of combinations of ‘k’ items that can be selected from a set of ‘n’ items. The binomial coefficient formula can be explicitly stated as given below.

Chart Formulas

where n! denotes the factorial of n.

An alternative name for the binomial coefficient is choose function; the binomial coefficient of n and k is often read as “n choose k”. Alternative notations include C(n, k), nCk (C for combination). These numbers are called binomial coefficients because they are coefficients in binomial theorem.

Using the formula

The Binomial method of the UtilityFunctions class returns the binomial coefficient for given n and k values.

Methods

Method Name Parameters Return Value
Binomial
  • The n value.
  • The k value.
An integer that represents the binomial coefficient value.

Example

Here is a code snippet that shows a sample usage.

using Syncfusion.Windows.Forms.Chart.Statistics;

int result = UtilityFunctions.Binomial(n, k);
Imports Syncfusion.Windows.Forms.Chart.Statistics

Dim int as result = UtilityFunctions.Binomial(n, k)

Inverse Beta Cumulative Distribution

This formula returns the inverse of Beta Cumulative Distribution.

Using the formula

The InverseBetaCumulativeDistribution method of the UtilityFunctions class returns the inverse of beta cumulative distribution ( for 1 >= p >= 0 , a > 0, b > 0 ).

Methods

Method Name Parameters Return Value

InverseBetaCumulativeDistribution

  • a: First Parameter of Beta function.
  • b: Second Parameter of Beta function.
  • p: The probability.
A double that inverses the beta cumulative distribution value.

Example

Here is a code snippet that shows a sample usage.

using Syncfusion.Windows.Forms.Chart.Statistics;

double result = UtilityFunctions.InverseBetaCumulativeDistribution (a, b, p);
Imports Syncfusion.Windows.Forms.Chart.Statistics

Dim double as result = UtilityFunctions.InverseBetaCumulativeDistribution (a, b, p)

Error Function

The Error function, denoted as Erf(x), gives the probability that a measurement under the influence of accidental errors has a distance less than x from the average value at the center. It is the integral of Gauss curve, that is usually normalized to one with a factor of 2/Öp. It is otherwise called as integrated Gauss function or Gauss Error function.

Chart Formulas

Here is the plot of error function.

Chart Formulas

Using the formula

The Erf method of the UtilityFunctions class returns integral of the Gauss curve for x > 0.

Methods

Method Name Parameters Return Value
Erf x: must be greater than zero. A double that represents the Gauss integral.

Example

Here is a code snippet that shows a sample usage.

using Syncfusion.Windows.Forms.Chart.Statistics;

int double = UtilityFunctions.Erf(x);
Imports Syncfusion.Windows.Forms.Chart.Statistics

Dim double as result = UtilityFunctions.Erf(x)

Factorial

The Factorial function returns the factorial value of a given number. In mathematics, the factorial of a natural number n is the product of all positive integers less than or equal to n. It is denoted as n! and pronounced “n factorial”, or colloquially “n shriek”, “n bang” or “n crit”. Factorial finds its main application in combinatorics like Permutations and Combinations and is also used in Number Theory.

The factorial function is defined by the following expression.

Chart Formulas

which is equivalent to n! = n . (n-1) . ….. . 2 . 1.

The above definition incorporates the convention that the product of no numbers at all is 1, i.e., 0! = 1.

Using the formula

The Factorial method of the UtilityFunctions class returns the factorial value for any positive integer.

Methods

Method Name Parameters Example

Factorial

n: The number whose factorial should be found out. An integer that returns the factorial of n.

Example

Here is a code snippet that shows a sample usage.

using Syncfusion.Windows.Forms.Chart.Statistics;

int result = UtilityFunctions.Factorial(int n);
Imports Syncfusion.Windows.Forms.Chart.Statistics

Dim int as result = UtilityFunctions.Factorial(int n)

F Cumulative Distribution

This formula returns cumulative F Distribution which can be defined as the ratio of two chi-square distributions. The formula can be expressed as given below.

Chart Formulas

where,

U1 is the first chi square distribution with d1 degrees of freedom and

U2 is the second chi square distribution with d2 degrees of freedom.

Using the Formula

FCumulativeDistribution is calculated using the Statistics.UtilityFunctions class. The following table describes the F Cumulative distribution method.

Methods

Method Name Parameters Return Value

FCumulativeDistribution

  • fValue: The F value for which you want the distribution.
  • firstDegreeOfFreedom: an integer value that represents the first degree of freedom.
  • secondDegreeOfFreedom: an integer value that represents the second degree of freedom.
A double that represents T cumulative distribution.

Example

Here is a code snippet that shows a sample usage.

using Syncfusion.Windows.Forms.Chart.Statistics;

double x = Statistics.UtilityFunctions. FCumulativeDistribution( fValue, firstDegreeOfFreedom, secondDegreeOfFreedom );
Imports Syncfusion.Windows.Forms.Chart.Statistics

double x = Statistics.UtilityFunctions. FCumulativeDistribution(fValue, firstDegreeOfFreedom, secondDegreeOfFreedom)

Gamma Function

The Gamma Function is an attempt to generalize the factorial function to real and complex numbers. It is related to the factorial function by

Chart Formulas

The Gamma Function

For a complex number x with a positive real part, the function can be given by

Chart Formulas

Special Values of gamma function

Chart Formulas

Using the Formula

The Gamma function is calculated using the Statistics.UtilityFunctions class. The following table describes the parameters and the return value of the gamma function.

Methods

Method Name Parameters Return Value

Gamma

p: a value for which the gamma value is required. A double that represents the gamma function value.

Example

Here is a code snippet that shows a sample usage.

using Syncfusion.Windows.Forms.Chart.Statistics;

double x = Statistics.UtilityFunctions.Gamma( p );
Imports Syncfusion.Windows.Forms.Chart.Statistics

double x = Statistics.UtilityFunctions.Gamma( p )

Gamma Cumulative Distribution

The formula for the cumulative distribution function for the gamma distribution is,

Chart Formulas

where is the gamma function defined above and is the incomplete gamma function. The incomplete gamma function has the formula.

Chart Formulas

Example

Here is a code snippet that shows a sample usage.

ChartSeries series = new ChartSeries("a=2");

for(double i = 0; i <= 20;i = i+2)

{

// Calculate Gamma Cumulative function for a points and plot the points in chart control.

 series.Points.Add (i,Syncfusion.Windows.Forms.Chart.Statistics.UtilityFunctions.GammaCumulativeDistribution(2.0,i));

}

series.Type=ChartSeriesType.Spline;

series.Text=series.Name;

this.ChartControl1.Series.Add(series);
Dim series As ChartSeries=Me.ChartControl1.Model.NewSeries("a=2")

For i As Double = 0 To 20 Step 2

' Calculate Gamma Cumulative function for a points and plot the points in chart control.

series.Points.Add(i,Syncfusion.Windows.Forms.Chart.Statistics.UtilityFunctions.GammaCumulativeDistribution(2.0,i))

Next i

series.Type=ChartSeriesType.Spline

series.Text=series.Name

Me.ChartControl1.Series.Add(series)

Inverse Error Function

The Inverse Error function, which is a rational approximation of the error function, gives the element-by-element inverse of the error function. The absolute value of the relative error is less than 1.15 -10.9 in the entire region.

Using the formula

The below table describes this function in detail.

Methods

Method Name Parameters Return Value

InverseErrorFunction

x must be less than 1.15-10.9 A double that gives the inverse of error function.

Example

Here is a code snippet that shows a sample usage.

using Syncfusion.Windows.Forms.Chart.Statistics;

int double = UtilityFunctions.InverseErf(x);
Imports Syncfusion.Windows.Forms.Chart.Statistics

Dim double as result = UtilityFunctions.InverseErf(x)

Inverse F Cumulative Distribution

This formula returns the inverse of the F cumulative distribution.

Using the Formula

InverseFCumulativeDistribution is calculated using the Statistics.UtilityFunctions class. The following table describes its parameters and its values.

Methods

Method Name Parameters Return Value

InverseFCumulativeDistribution

  • fValue: The F value for which you need the distribution.
  • firstDegreeOfFreedom: an integer value that represents the first degree of freedom.
  • secondDegreeOfFreedom: an integer value that represents the second degree of freedom.
A double that represents the inverse F cumulative distribution.

Example

Here is a code snippet that shows a sample usage.

using Syncfusion.Windows.Forms.Chart.Statistics;

double x= Statistics.UtilityFunctions. InverseFCumulativeDistribution( fValue, firstDegreeOfFreedom, secondDegreeOfFreedom );
Imports Syncfusion.Windows.Forms.Chart.Statistics

double x= Statistics.UtilityFunctions. InverseFCumulativeDistribution(fValue, firstDegreeOfFreedom, secondDegreeOfFreedom)

Inverse Normal Distribution

This formula returns an approximation of the inverse of the standard normal cumulative distribution. That is, for a given P, it returns an approximation to the x satisfying P=Pr {z is smaller than x} where z is a random variable from the standard normal distribution.

Using the Formula

InverseNormalDistribution is calculated using the Statistics.UtilityFunctions class. The following table describes its parameters and its values.

Methods

Method Name Parameters Example

InverseNormalDistribution

p: the probability at which the function value is evaluated. p must be in (0,1) range. A double that represents the inverse of the normal distribution function.

The algorithm uses a minimax approximation by rational functions and the result has a relative error whose absolute value is less than 1.15e-9.

Example

Here is a code snippet that shows a sample usage.

using Syncfusion.Windows.Forms.Chart.Statistics;

double x = Statistics.UtilityFunctions.InverseNormalDistribution( p );
Imports Syncfusion.Windows.Forms.Chart.Statistics

double x = Statistics.UtilityFunctions.InverseNormalDistribution( p )

Normal Distribution

This formula yields the value of the standard normal cumulative distribution. Normal distributions are symmetric and have bell-shaped density curves with a single peak. Two factors, the mean () and the standard deviation (), come into place when we speak of normal distribution. The mean indicates the peak of the density curve and the standard deviation indicates the spread of the bell curve.

The normal density function is given by,

Chart Formulas

Chart Formulas

Different values of and  yield different normal density curves and hence different normal distributions. All normal density curves satisfy the following property which is often referred to as the__Empirical Rule.

  • 68% of the observations fall within 1 standard deviation of the mean, that is, between -  and + .
  • 95% of the observations fall within 2 standard deviations of the mean, that is, between - 2 and + 2.
  • 99.7% of the observations fall within 3 standard deviations of the mean, that is, between - 3 and + 3.

Thus, for a normal distribution, almost all values lie within three standard deviations of the mean.

Using the Formula

NormalDistribution is calculated using the Statistics.UtilityFunctions class. The following table describes this formula’s parameters and its values.

Methods

Method Name Parameters Return Value

NormalDistribution

zValue: The value for which the distribution is required. A double that represents the standard normal cumulative distribution value.

Example

Here is a code snippet that shows a sample usage.

using Syncfusion.Windows.Forms.Chart.Statistics;

double x = Statistics.UtilityFunctions.NormalDistribution( p );
Imports Syncfusion.Windows.Forms.Chart.Statistics

double x = Statistics.UtilityFunctions.NormalDistribution( p )

Normal Distribution Density

In probability and statistics, the log-normal distribution is the probability of distribution of any random variable whose logarithm is normally distributed (the base of the logarithmic function is immaterial in that loga x is normally distributed if and only if logb X is normally distributed). If x is a random variable with a normal distribution, then exp(X) will have a log-normal distribution.

“Log-normal” can also be written as “log normal”, “lognormal” or “logistic normal”.

A variable might be modeled as log-normal if it can be thought of as the multiplicative product of many small independent factors. A typical example of this is the long-term return rate on a stock investment: it can be considered as the product of the daily return rates.

The log-normal distribution has a probability density function (pdf),

Chart Formulas

for x > 0, where µ and s are the median and standard deviation of the variable’s logarithm. The expected value is,

Chart Formulas

and the variance is,

Chart Formulas

Chart Formulas

Using the formula

Methods

Method Name Parameters Return Value

NormalDistributionDensity

  • x: the value at which the distribution density is evaluated.
  • m: the expected value of distribution.
  • sigma: the variance of distribution.
A double that represents the Normal Distribution Density function value.

Example

Here is a code snippet that shows a sample usage.

using Syncfusion.Windows.Forms.Chart.Statistics;

double result = UtilityFunctions.NormalDistributionDensity(x, m ,sigma);
Imports Syncfusion.Windows.Forms.Chart.Statistics

Dim double as result = UtilityFunctions.NormalDistributionDensity(x, m ,sigma)

Inverse T Cumulative Distribution

This formula computes the inverse of the cumulative distribution for T-statistic.

Using the Formula

InverseTCumulativeDistribution is calculated using the Statistics.UtilityFunctions class. The following table describes this function’s parameters and its values.

Methods

Method Name Parameters Return Value

InverseTCumulativeDistribution

  • p: the alpha value (probability).
  • degreeOfFreedom: an integer value that represents the degree of freedom.
  • oneTail: If true, one-tailed distribution is used; otherwise two-tailed distribution is used.
A double that represents the Inverse of T cumulative distribution function probability.

Example

Here is a code snippet that shows a sample usage.

using Syncfusion.Windows.Forms.Chart.Statistics;

double x= Statistics.UtilityFunctions. InverseTCumulativeDistribution(p, degreeOfFreedom,OneTail );
Imports Syncfusion.Windows.Forms.Chart.Statistics

double x= Statistics.UtilityFunctions. InverseTCumulativeDistribution(p, degreeOfFreedom,OneTail )

TCumulative Distribution

This formula will return the T cumulative distribution (student’s t-distribution) for a degree of freedom > 0. When there is a need to estimate the mean of a normally distributed population for a given sample, the t-distribution comes into action. It is the basis of the popular t-tests to find out the difference between two sample means.

For a sample with size n drawn from a normal population with mean  and standard deviation . Let <p>Chart Formulas</p>

and s denote the sample mean and sample standard deviation respectively. Then the quantity

Chart Formulas

gives the t-distribution for n-1 degrees of freedom.

Using the Formula

TCumulativeDistribution is calculated using the Statistics.UtilityFunctions class. The following table describes this function’s parameters and its values.

Methods

Method Name Parameters Return Value

TCumulativeDistribution

  • t Value: the T value for which you want the distribution.
  • degreeOfFreedom: an integer value that represents the degree of freedom.
  • oneTail: If true, one-tailed distribution is used; otherwise two-tailed distribution is used.
A double that represents the T cumulative distribution function probability.

Example

Here is a code snippet that shows a sample usage.

using Syncfusion.Windows.Forms.Chart.Statistics;

double x= Statistics.UtilityFunctions.TCumulativeDistribution(tvalue, degreeOfFreedom,OneTail );
Imports Syncfusion.Windows.Forms.Chart.Statistics

double x= Statistics.UtilityFunctions.TCumulativeDistribution(tvalue, degreeOfFreedom,OneTail )