| 24 | } |
| 25 | |
| 26 | int main() |
| 27 | { |
| 28 | running_stats<double> rs; |
| 29 | |
| 30 | double tp1 = 0; |
| 31 | double tp2 = 0; |
| 32 | |
| 33 | // We first generate the data and add it sequentially to our running_stats object. We |
| 34 | // then print every fifth data point. |
| 35 | for (int x = 1; x <= 100; x++) |
| 36 | { |
| 37 | tp1 = x/100.0; |
| 38 | tp2 = sinc(pi*x/100.0); |
| 39 | rs.add(tp2); |
| 40 | |
| 41 | if(x % 5 == 0) |
| 42 | { |
| 43 | cout << " x = " << tp1 << " sinc(x) = " << tp2 << endl; |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | // Finally, we compute and print the mean, variance, skewness, and excess kurtosis of |
| 48 | // our data. |
| 49 | |
| 50 | cout << endl; |
| 51 | cout << "Mean: " << rs.mean() << endl; |
| 52 | cout << "Variance: " << rs.variance() << endl; |
| 53 | cout << "Skewness: " << rs.skewness() << endl; |
| 54 | cout << "Excess Kurtosis " << rs.ex_kurtosis() << endl; |
| 55 | |
| 56 | return 0; |
| 57 | } |
| 58 | |