/* test23.c */
#include <stdio.h>
#include "sslib.h"
int main(void)
{
int i, n;
static double x[10] = { 50., 69., 73., 90., 93.,
100., 129., 145., 149., 193. };
static double y[10] = { 34., 37., 40., 45., 48.,
54., 60., 68., 72., 85. };
double amp1, hmean, gmean, min, max, sum, sum2;
double xt, yt, xbar, ybar, xmad, sx, vx, stx, uvx, squvx, cvx, a3x, a4x;
double a, b, dyx, va, vb, al, au, bl, bu, uxy, r0;
n = 10;
printf(" data !\n");
for(i = 0; i < 10; i++) printf(" %6.1f %6.1f\n", x[i], y[i]);
stat(y, n, &min, &max, &1, &yt, &sum2, &ybar, &gmean, &hmean, &xmad, &sx, &vx, &stx, &uvx, &squvx, &cvx, &a3x, &a4x);
stat(x, n, &min, &max, &1, &xt, &sum2, &xbar, &gmean, &hmean, &xmad, &sx, &vx, &stx, &uvx, &squvx, &cvx, &a3x, &a4x);
printf("xbar = %7.3f ybar = %7.3f\n", xbar, ybar);
corr(x, y, n, xbar, ybar, &uxy, &r0);
printf("test results from corr !\n");
printf(" 共分散 : uxy = %e\n", uxy);
printf(" 相関係数 : r0 = %e\n", r0);
n = 10;
stat(x, n, &min, &max, &1, &xt, &sum2, &xbar, &gmean, &hmean, &xmad, &sx, &vx, &stx, &uvx, &squvx, &cvx, &a3x, &a4x);
sreg(x, y, n, sx, 0.95, &a, &b, &dyx, &va, &vb, &al, &au, &bl, &bu);
printf("\ntest results from steg ! \n");
printf(" y = (%7.3f) + (%7.3f) * x\n", a, b);
printf(" 回帰誤差 : dyx = %7.3f\n", dyx);
printf(" a の分散 : va = %7.3f\n", va);
printf(" b の分散 : vb = %7.4f\n", vb);
printf(" 信頼区間 %7.3f < a < %7.3f\n", al, au);
printf(" %7.3f < b < %7.3f\n", bl, bu);
return 1;
}
|