確率分布ライブラリ 使用例



[ 簡単な説明 ]

確率分布ライブラリの使用例です。

プログラム・ソース("test21.c")           top (先頭に戻る)
/*	test21.c		*/
#include	<stdio.h>
#include	"sslib.h"

int main(void)
{
	double u, w;
	int n;

	for(u = -3.; u <= 3.; u += 0.5)
	{
		w = qnorm(u);
		printf("u=%15.7e   qnorm(u)=%15.7e   pnorm(qnorm())=%15.7e\n", u, w, pnorm(w));
	}
	printf("χ2 = %f\n", (u = 15.5));
	for(n = 1; n <= 15; n++)
	{
		w = qchi(u, n);
		printf("n=%2d   qchi(χ2, n)=%15.7e   pchi(qchi(),n)=%15.7e\n", n, w, pchi(w, n));
	}
	printf("q = %f\n", (u = 0.05));
	for(n = 1; n <= 10; n++)
	{
		w = pt(u, n);
		printf("n=%2d   pt(q, n)=%15.7e   qt(pt(),n)=%15.7e\n", n, w, qt(w, n));
	}
	printf("q = %f , n1 = 6\n", (u = 0.1));
	for(n = 1; n <= 10; n++)
	{
		w = pf(u, 6, n);
		printf("n=%2d   pf(q, 6, n)=%15.7e   qf(pf(), 6, n)=%15.7e\n", n, w, qf(w, 6, n));
	}

	return 1;
}

出力結果           top (先頭に戻る)
u= -3.0000000e+00   qnorm(u)=  1.3498974e-03   pnorm(qnorm())= -3.0000001e+00
u= -2.5000000e+00   qnorm(u)=  6.2096651e-03   pnorm(qnorm())= -2.5000000e+00
u= -2.0000000e+00   qnorm(u)=  2.2750133e-02   pnorm(qnorm())= -2.0000000e+00
u= -1.5000000e+00   qnorm(u)=  6.6807201e-02   pnorm(qnorm())= -1.5000000e+00
u= -1.0000000e+00   qnorm(u)=  1.5865525e-01   pnorm(qnorm())= -9.9999999e-01
u= -5.0000000e-01   qnorm(u)=  3.0853754e-01   pnorm(qnorm())= -5.0000001e-01
u=  0.0000000e+00   qnorm(u)=  5.0000000e-01   pnorm(qnorm())=  0.0000000e+00
u=  5.0000000e-01   qnorm(u)=  6.9146246e-01   pnorm(qnorm())=  5.0000001e-01
u=  1.0000000e+00   qnorm(u)=  8.4134475e-01   pnorm(qnorm())=  9.9999999e-01
u=  1.5000000e+00   qnorm(u)=  9.3319280e-01   pnorm(qnorm())=  1.5000000e+00
u=  2.0000000e+00   qnorm(u)=  9.7724987e-01   pnorm(qnorm())=  2.0000000e+00
u=  2.5000000e+00   qnorm(u)=  9.9379033e-01   pnorm(qnorm())=  2.5000000e+00
u=  3.0000000e+00   qnorm(u)=  9.9865010e-01   pnorm(qnorm())=  3.0000001e+00
χ2 = 15.500000
n= 1   qchi(χ2, n)=  8.2504917e-05   pchi(qchi(),n)=  1.5500008e+01
n= 2   qchi(χ2, n)=  4.3074254e-04   pchi(qchi(),n)=  1.5500000e+01
n= 3   qchi(χ2, n)=  1.4355855e-03   pchi(qchi(),n)=  1.5487072e+01
n= 4   qchi(χ2, n)=  3.7689972e-03   pchi(qchi(),n)=  1.5497514e+01
n= 5   qchi(χ2, n)=  8.4265021e-03   pchi(qchi(),n)=  1.5499656e+01
n= 6   qchi(χ2, n)=  1.6704734e-02   pchi(qchi(),n)=  1.5499991e+01
n= 7   qchi(χ2, n)=  3.0098343e-02   pchi(qchi(),n)=  1.5499981e+01
n= 8   qchi(χ2, n)=  5.0122055e-02   pchi(qchi(),n)=  1.5499949e+01
n= 9   qchi(χ2, n)=  7.8085992e-02   pchi(qchi(),n)=  1.5499943e+01
n=10   qchi(χ2, n)=  1.1486811e-01   pchi(qchi(),n)=  1.5499956e+01
n=11   qchi(χ2, n)=  1.6006668e-01   pchi(qchi(),n)=  1.5516584e+01
n=12   qchi(χ2, n)=  2.1461589e-01   pchi(qchi(),n)=  1.5512614e+01
n=13   qchi(χ2, n)=  2.7672922e-01   pchi(qchi(),n)=  1.5508193e+01
n=14   qchi(χ2, n)=  3.4461503e-01   pchi(qchi(),n)=  1.5503804e+01
n=15   qchi(χ2, n)=  4.1605067e-01   pchi(qchi(),n)=  1.5499760e+01
q = 0.050000
n= 1   pt(q, n)=  1.2706210e+01   qt(pt(),n)=  4.9999979e-02
n= 2   pt(q, n)=  4.3026100e+00   qt(pt(),n)=  5.0000920e-02
n= 3   pt(q, n)=  3.1824100e+00   qt(pt(),n)=  5.0001394e-02
n= 4   pt(q, n)=  2.7764100e+00   qt(pt(),n)=  5.0001796e-02
n= 5   pt(q, n)=  2.5705100e+00   qt(pt(),n)=  5.0004359e-02
n= 6   pt(q, n)=  2.4468986e+00   qt(pt(),n)=  5.0000898e-02
n= 7   pt(q, n)=  2.3646190e+00   qt(pt(),n)=  5.0000389e-02
n= 8   pt(q, n)=  2.3060017e+00   qt(pt(),n)=  5.0000187e-02
n= 9   pt(q, n)=  2.2621560e+00   qt(pt(),n)=  5.0000098e-02
n=10   pt(q, n)=  2.2281382e+00   qt(pt(),n)=  5.0000055e-02
q = 0.100000 , n1 = 6
n= 1   pf(q, 6, n)=  5.8204100e+01   qf(pf(), 6, n)=  1.0000027e-01
n= 2   pf(q, 6, n)=  9.3255100e+00   qf(pf(), 6, n)=  1.0000020e-01
n= 3   pf(q, 6, n)=  5.2847100e+00   qf(pf(), 6, n)=  1.0000052e-01
n= 4   pf(q, 6, n)=  4.0097100e+00   qf(pf(), 6, n)=  1.0000151e-01
n= 5   pf(q, 6, n)=  3.4045100e+00   qf(pf(), 6, n)=  9.9999824e-02
n= 6   pf(q, 6, n)=  3.0545100e+00   qf(pf(), 6, n)=  1.0000256e-01
n= 7   pf(q, 6, n)=  2.8273100e+00   qf(pf(), 6, n)=  1.0000602e-01
n= 8   pf(q, 6, n)=  2.6683100e+00   qf(pf(), 6, n)=  1.0000203e-01
n= 9   pf(q, 6, n)=  2.5508100e+00   qf(pf(), 6, n)=  1.0000408e-01
n=10   pf(q, 6, n)=  2.4605100e+00   qf(pf(), 6, n)=  1.0000699e-01