Calculate skewness

How can I calculate my skewness

here is my code up until now
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
int main()
{
	cout << "Please input 10 numbers..." << endl;
	int a; int b; int c; int d; int e; int f; int g; int h; int i; int j;
	cin >> a; cin >> b; cin >> c; cin >> d; cin >> e; cin >> f; cin >> g; cin >> h; cin >> i; cin >> j;

	int sum = a + b + c + d + e + f + g + h + i + j;
		
	int mean =(sum / 10);
	
	int var = ((a - mean)*(a - mean) + (b - mean)*(b - mean) + (c - mean)*(c - mean) + (d - mean)*(d - mean) + (e - mean)*(e - mean) + (a - mean)*(a - mean) + (f - mean)*(f - mean) + (g - mean)*(g - mean) + (h - mean)*(h - mean) + (i - mean)*(i - mean) + (j - mean)*(j - mean)) / 9; 

	int std = sqrt(var)

	int skew = 


	int iarr[4] = { mean, var, };

	cout << "The first moment is..." << iarr[0] << endl;
	cout << "The second moment is... " << iarr[1];


	cin.get(); 
	cin.get();
	return 0;
Here is a link a found for you , hope that might help :

http://www.johndcook.com/blog/standard_deviation/
Another link:
http://growingknowing.com/GKStatsBookSkewness.php

Also note:
int mean =(sum / 10);

Your mean will suffer from integer division truncation.

You certainly do not want these calculations to be stored in integers. Use doubles.
Last edited on
Topic archived. No new replies allowed.