|
[ 簡単な説明 ] 標準統計量ライブラリの使用例です。
|
/* test19.c */
#include <stdio.h>
#include <stdlib.h>
#include "sslib.h"
void prk(int a[], int n);
void pra(double a[], int n);
void prk(int a[], int n)
{
int i;
for(i = 0; i < n; i++) printf("%7d ", a[i]);
putchar('\n');
}
void pra(double a[], int n)
{
int i;
for(i = 0; i < n; i++) printf("%7.4f ", a[i]);
putchar('\n');
}
int main(void)
{
double a[100];
int k[100], i, n;
char s[100][7];
n = 100;
for(i = 0; i < n; i++) a[i] = (double)rand() / RAND_MAX;
pra(a, n);
sortd1(a, n);
sortd2(a, n);
pra(a, n);
sortdi1(a, n, k);
prk(k, n);
n = 100;
for(i = 0; i < n; i++) k[i] = rand() / 32;
prk(k, n);
sorti1(k, n);
prk(k, n);
return 1;
}
|
0.0106 0.0040 0.3352 0.0333 0.3557 0.2172 0.5370 0.1958 0.7003 0.9499
0.2748 0.4443 0.1090 0.6982 0.5643 0.0415 0.1652 0.8155 0.6855 0.7644
0.8276 0.9595 0.2194 0.4268 0.9526 0.8395 0.9232 0.8109 0.4510 0.6048
0.6617 0.5997 0.5492 0.7200 0.1140 0.4062 0.1214 0.6713 0.4749 0.4911
0.5643 0.3445 0.8687 0.2644 0.1798 0.4231 0.6948 0.1637 0.5383 0.6455
0.6234 0.0031 0.7872 0.2689 0.4611 0.3865 0.3768 0.5811 0.6035 0.2798
0.1706 0.8052 0.2950 0.3339 0.4086 0.2404 0.4140 0.0543 0.4941 0.9837
0.0016 0.4098 0.0697 0.0739 0.2543 0.9747 0.3551 0.4049 0.1971 0.1971
0.2117 0.2490 0.7581 0.8894 0.9054 0.7360 0.4613 0.5316 0.0353 0.1306
0.4580 0.4840 0.5970 0.2532 0.1146 0.7013 0.6493 0.8863 0.8756 0.0428
0.9837 0.9747 0.9595 0.9526 0.9499 0.9232 0.9054 0.8894 0.8863 0.8756
0.8687 0.8395 0.8276 0.8155 0.8109 0.8052 0.7872 0.7644 0.7581 0.7360
0.7200 0.7013 0.7003 0.6982 0.6948 0.6855 0.6713 0.6617 0.6493 0.6455
0.6234 0.6048 0.6035 0.5997 0.5970 0.5811 0.5643 0.5643 0.5492 0.5383
0.5370 0.5316 0.4941 0.4911 0.4840 0.4749 0.4613 0.4611 0.4580 0.4510
0.4443 0.4268 0.4231 0.4140 0.4098 0.4086 0.4062 0.4049 0.3865 0.3768
0.3557 0.3551 0.3445 0.3352 0.3339 0.2950 0.2798 0.2748 0.2689 0.2644
0.2543 0.2532 0.2490 0.2404 0.2194 0.2172 0.2117 0.1971 0.1971 0.1958
0.1798 0.1706 0.1652 0.1637 0.1306 0.1214 0.1146 0.1140 0.1090 0.0739
0.0697 0.0543 0.0428 0.0415 0.0353 0.0333 0.0106 0.0040 0.0031 0.0016
99 98 97 96 95 94 93 92 91 90
89 88 87 86 85 84 83 82 81 80
79 78 77 76 75 74 73 72 71 70
69 68 67 66 65 64 63 62 61 60
59 58 57 56 55 54 53 52 51 50
49 48 47 46 45 44 43 42 41 40
39 38 37 36 35 34 33 32 31 30
29 28 27 26 25 24 23 22 21 20
19 18 17 16 15 14 13 12 11 10
9 8 7 6 5 4 3 2 1 0
566 522 635 789 259 222 241 343 579 136
628 31 971 217 827 644 732 749 565 585
172 340 890 844 629 976 1015 1005 755 522
302 735 292 655 504 179 572 393 793 398
666 130 148 344 941 670 664 726 671 677
738 1021 431 575 385 1007 15 964 463 243
559 506 641 724 597 808 442 3 855 733
1010 468 361 961 659 578 715 228 317 919
73 980 627 83 867 744 690 947 505 292
697 317 363 773 1000 943 250 420 935 429
3 15 31 73 83 130 136 148 172 179
217 222 228 241 243 250 259 292 292 302
317 317 340 343 344 361 363 385 393 398
420 429 431 442 463 468 504 505 506 522
522 559 565 566 572 575 578 579 585 597
627 628 629 635 641 644 655 659 664 666
670 671 677 690 697 715 724 726 732 733
735 738 744 749 755 773 789 793 808 827
844 855 867 890 919 935 941 943 947 961
964 971 976 980 1000 1005 1007 1010 1015 1021
|
/* test20.c */
#include <stdio.h>
#include "sslib.h"
int main(void)
{
static double a[6] = {14., 16., 18., 20., 25., 27.};
double min, max, amp, sum, sum2, ave, gmean, hmean, amad, s, v, st, uv, squv, cv;
double sk, ku;
int i, n;
n = 6;
stat(a, n, &min, &max, &, &sum, &sum2, &ave, &gmean, &hmean, &amad, &s,
&v, &st, &uv, &squv, &cv, &sk, &ku);
printf("*** data ***\n");
for(i = 0; i < n; i++) printf("%6.1f", a[i]);
putchar('\n');
printf("総和(total, sum) : %e\n", sum);
printf("二乗和(sum of square) : %e\n", sum2);
printf("最大値(maximum) : %e\n", max);
printf("最小値(minimum) : %e\n", min);
printf("中点値(mid point) : %e\n", amp);
printf("算術平均値(arithmetic mean) : %e\n", ave);
printf("幾何平均値(geometric mean) : %e\n", gmean);
printf("調和平均値(harmonic mean) : %e\n", hmean);
printf("平均絶対偏差(mean absolute deviation) : %e\n", amad);
printf("偏差平方和(sum of square of deviation) : %e\n", s);
printf("分散(variance) : %e\n", v);
printf("標準偏差(standard deviation) : %e\n", st);
printf("不偏分散(unbiased estimate of population variance) : %e\n", uv);
printf("不偏分散平方根(square root of UV) : %e\n", squv);
printf("算術平均に対する変動係数(coefficient of variance) : %e\n", cv);
printf("歪度(skewness) : %e\n", sk);
printf("尖度(kurtosis) : %e\n", ku);
return 1;
}
|
*** data *** 14.0 16.0 18.0 20.0 25.0 27.0 総和(total, sum) : 1.200000e+02 二乗和(sum of square) : 2.530000e+03 最大値(maximum) : 2.700000e+01 最小値(minimum) : 1.400000e+01 中点値(mid point) : 2.050000e+01 算術平均値(arithmetic mean) : 2.000000e+01 幾何平均値(geometric mean) : 1.946745e+01 調和平均値(harmonic mean) : 1.895608e+01 平均絶対偏差(mean absolute deviation) : 4.000000e+00 偏差平方和(sum of square of deviation) : 1.300000e+02 分散(variance) : 2.166667e+01 標準偏差(standard deviation) : 4.654747e+00 不偏分散(unbiased estimate of population variance) : 2.600000e+01 不偏分散平方根(square root of UV) : 5.099020e+00 算術平均に対する変動係数(coefficient of variance) : 2.327373e+01 歪度(skewness) : 2.974631e-01 尖度(kurtosis) : 1.631006e+00 |