The standard deviation (usually abbreviated SD, sd, or just s) of a bunch of numbers tells you how much the individual numbers tend to differ (in either direction) from the mean. It’s calculated as follows: This formula is saying that you calculate the standard deviation of a set of N numbers (Xi) by subtracting the. This page was last modified on 6 July 2018, at 06:31. This page has been accessed 13,863 times. Privacy policy; About cppreference.com; Disclaimers.
- Std Dev Variance
- Std Dev Variance In C 1
- Standard Deviation Variance Correlation
- Std Dev Variance In Construction
The uniform distribution is used to describe a situation where all possible outcomes of a random experiment are equally likely to occur. You can use the variance and standard deviation to measure the “spread” among the possible values of the probability distribution of a random variable.
For example, suppose that an art gallery sells two types of art work: inexpensive prints and original paintings. The length of time that the prints remain in inventory is uniformly distributed over the interval (0, 40). For example, some prints are sold immediately; no print remains in inventory for more than 40 days. For the paintings, the length of time in inventory is uniformly distributed over the interval (5, 105). For example, each painting requires at least 5 days to be sold and may take up to 105 days to be sold.
The variance and the standard deviation measure the degree of dispersion (spread) among the values of a probability distribution. In the art gallery example, the inventory times of the prints are much closer to each other than for the paintings. As a result, the variance and standard deviation are much lower for the prints because the range of possible values is much smaller.
For the uniform distribution defined over the interval from a to b, the variance equals
The standard deviation is the square root of the variance:
For example, the variance of the uniform distribution defined over the interval (1, 5) is computed as follows:
The standard deviation is:
Mean, Variance and Standard Deviation are widely used in statistical application. It is a good idea to start writing program in C++ on this.
Note the difference between sample variance and population variance, similarly sample standard deviation and population standard deviation
The complete program and test run output are given below:
Source Code
#include<iostream>
#include<string>
#include<math.h>
class StdDeviation
{
private:
int max;
double value[100];
double mean;
public:
double CalculateMean()
{
double sum = 0;
for(int i = 0; i < max; i++)
sum += value[i];
return (sum / max);
}
double CalculateVariane()
{
mean = CalculateMean();
double temp = 0;
for(int i = 0; i < max; i++)
{
temp += (value[i] - mean) * (value[i] - mean) ;
}
return temp / max;
}
double CalculateSampleVariane()
{
mean = CalculateMean();
double temp = 0;
for(int i = 0; i < max; i++)
{
temp += (value[i] - mean) * (value[i] - mean) ;
}
return temp / (max - 1);
}
int SetValues(double *p, int count)
{
if(count > 100)
return -1;
max = count;
for(int i = 0; i < count; i++)
value[i] = p[i];
return 0;
}
double GetStandardDeviation()
{
return sqrt(CalculateVariane());
}
double GetSampleStandardDeviation()
{
return sqrt(CalculateSampleVariane());
}
};
int main()
{
double arrNumbers[] =
{
15.17, 16.94, 14.94, 14.99, 13.77, 13.75,
12.67, 12.14, 12.59, 12.48, 14.81, 14.29,
12.74, 12.52, 11.65, 12.24, 11.42, 12.25,
12.72, 11.64, 11.09, 11.22, 11.50, 11.36,
11.84, 12.18, 11.04, 10.90, 11.80, 11.84,
};
StdDeviation sd;
sd.SetValues(arrNumbers, sizeof(arrNumbers) / sizeof(arrNumbers[0]));
double mean = sd.CalculateMean();
double variance = sd.CalculateVariane();
double samplevariance = sd.CalculateSampleVariane();
double sampledevi = sd.GetSampleStandardDeviation();
double devi = sd.GetStandardDeviation();
char buf[1024];
sprintf(buf, 'Total Numbersttt: %10dn', sizeof(arrNumbers) / sizeof(arrNumbers[0]));
std::cout << buf;
sprintf(buf, 'Meantttt: %10.5lfnPopulation Variancett: %10.4lfn', mean, variance);
std::cout << buf;
sprintf(buf, 'Sample variancettt: %10.4lfn', samplevariance);
std::cout << buf;
sprintf(buf, 'Population Standard Deviationt: %10.4lfn', devi);
std::cout << buf;
sprintf(buf, 'Sample Standard Deviationt: %10.4lfn', sampledevi);
std::cout << buf;
return 0;
Std Dev Variance
}
Output
Total Numbers:30
Mean:12.68300
Population Variance:2.1607
Sample variance:2.2352
Population Standard Deviation:1.4699
Sample Standard Deviation:1.4951
Std Dev Variance In C 1
Press any key to continue . . .
Comments are closed.