メイン median-conf.html Last modified: Sep 01, 2009
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;CHARSET=EUC-JP">
<link rel="shortcut icon" href="../favicon.ico">
<title>JavaScript</title>
<script src="io.js">document.write("io.js ファイルが見つかりません??<br>")</script>
<script language="JavaScript">
<!--
var MP_LIMIT = 260
var cl = new Array("95.0%", "99.0%")
function compareNumbers(a, b)
{
// return a - b
if (a > b) return 1
else if (a == b) return 0
else return -1
}
// 中央値を求める
//
function get_median(x, n)
{
var n2
if (n == 1) {
return x[0]
}
else if (n == 2) {
return (x[0]+x[1])/2
}
x.sort(compareNumbers)
n2 = Math.floor(n/2)
return n%2 == 1 ? x[n2] : (x[n2-1]+x[n2])/2
}
function head(sw, str)
{
printf("信頼率 %s%s\n", str, sw ? " 正確な信頼率" : "")
}
// 対応のある場合の結果出力 必ず正確な信頼率が求まる
//
function out_sub_paired(nth, diff, n, i, p1)
{
var nt
nt = n*(n+1)/2
if (p1 != 0) {
printf("%s [ %12.6g, %12.6g ] %7.3f%%\n", cl[nth], diff[i-1], diff[nt-i], p1*100.0)
}
else if (nth == 0) {
printf("%s [ %12s, %12s ]\n", cl[nth], "---", "---")
}
}
// 対応のある場合の信頼区間の出力
//
function out_paired_result(diff, n, str)
{
head(1, str)
out_sub_paired(0, diff, n, mp_t[(n-1)*4], mp_t[(n-1)*4+1])
out_sub_paired(1, diff, n, mp_t[(n-1)*4+2], mp_t[(n-1)*4+3])
}
function onesample_a(x1, n)
{
var i, j, nt, diff
diff = new Array(n*(n+1)/2)
nt = 0
for (i = 0; i < n; i++) {
for (j = 0; j <= i; j++) {
diff[nt++] = (x1[i]+x1[j])/2
}
}
sep(60)
printf("推定された中央値 %.6g\n\n", get_median(diff, nt))
out_paired_result(diff, n, " 中央値の信頼区間 ")
}
// 1標本の場合 n > 690 正規近似
//
function out_sub_onesample(nth, x1, n, i, j)
{
if (n >= i && i > 0 && n >= j && j > 0) {
printf("%s [ %12.6g, %12.6g ] 近似\n", cl[nth], x1[i-1], x1[j-1])
}
else if (nth == 0) {
printf("%s [ %12s, %12s ]\n", cl[nth], "---", "---")
}
}
// 1標本で n > 690 のとき、正規近似による信頼区間の出力
//
function out_onesample_result(x1, n)
{
var i, r, s, z
z = new Array(1.959963985, 2.575829304)
head(0, " 中央値の信頼区間 ")
for (i = 0; i < 2; i++) {
r = Math.floor((n-z[i]*Math.sqrt(n))/2.0+0.5)
s = Math.floor((n+z[i]*Math.sqrt(n))/2.0+1.5)
out_sub_onesample(i, x1, n, r, s)
}
}
// 1標本で n <= 690 のとき、 二項分布を利用 正確な信頼率が求まる
//
function out_sub_onesample2(nth, x1, n, i, j, p)
{
if (n >= i && i >= 0 && n >= j && j >= 0) {
printf("%s [ %12.6g, %12.6g ] %7.3f%%\n", cl[nth], x1[i], x1[j], p*100.0)
}
else if (nth == 0) {
printf("%s [ %12s, %12s ]\n", cl[nth], "---", "---")
}
}
// 二項分布の限界点
//
function binomial(n, alpha, sw)
{
var i, old, temp, p, combination
p = combination = 0.0
temp = n*Math.log(0.5)
for (i = 0; i <= n; i++) {
old = p
p += Math.exp(combination+temp)
if (p > alpha/2) {
return sw == 1 ? i : 1-2*old
}
combination += Math.log((n-i)/(i+1))
}
}
// 1標本で n <= 690 のとき、 二項分布に基づいた信頼区間の出力
//
function out_onesample_result2(x1, n)
{
var l95, l99
var p95, p99
head(1, " 中央値の信頼区間 ")
l95 = binomial(n, 0.05, 1)
p95 = binomial(n, 0.05, 0)
l99 = binomial(n, 0.01, 1)
p99 = binomial(n, 0.01, 0)
out_sub_onesample2(0, x1, n, l95, n-l95-1, p95)
out_sub_onesample2(1, x1, n, l99, n-l99-1, p99)
}
// 1標本の場合 正規近似、二項分布
//
function onesample_b(x1, n)
{
printf("\n")
if (n > 690) {
printf("正規近似による区間推定\n\n")
out_onesample_result(x1, n) // x1 はここではソート済み
}
else {
printf("二項分布に基づく区間推定\n\n")
out_onesample_result2(x1, n) // x1 はここではソート済み
}
}
function calc(data_string)
{
var data, data2, nc, i, j
if ((data = getdata(data_string, -1)) != false) {
nc = 0
data2 = new Array()
for (i = 0; i < data.length; i++) {
for (j = 0; j < data[i].length; j++) {
data2[nc++] = data[i][j]
}
}
if (nc < 2) {
printf("ケース数が1以下です\n")
return
}
printf("有効ケース数 %i\n標本中央値 %.6g\n\n", nc, get_median(data2, nc))
if (nc <= MP_LIMIT) {
onesample_a(data2, nc)
}
onesample_b(data2, nc)
}
sep(60)
}
var mp_t = new Array(-1, 0.00000, -1, 0.00000, -1, 0.00000, -1, 0.00000, -1, 0.00000, -1, 0.00000, -1, 0.00000, -1, 0.00000, -1, 0.00000, -1, 0.00000, 1, 0.96875, -1, 0.00000, 3, 0.95312, -1, 0.00000, 4, 0.96094, 1, 0.99219, 6, 0.96094, 2, 0.99219, 9, 0.95117, 4, 0.99023,
11, 0.95801, 6, 0.99023, 14, 0.95752, 8, 0.99072, 18, 0.95215, 10, 0.99194, 22, 0.95056, 13, 0.99146, 26, 0.95209, 16, 0.99164, 30, 0.95569, 20, 0.99081, 35, 0.95523, 24, 0.99066, 41, 0.95172, 28, 0.99104, 47, 0.95063, 33, 0.99055, 53, 0.95156, 38, 0.99056,
59, 0.95401, 43, 0.99098, 66, 0.95384, 49, 0.99073, 74, 0.95156, 55, 0.99085, 82, 0.95094, 62, 0.99042, 90, 0.95174, 69, 0.99037, 99, 0.95065, 76, 0.99062, 108, 0.95090, 84, 0.99039, 117, 0.95225, 92, 0.99046, 127, 0.95197, 101, 0.99012, 138, 0.95029, 110, 0.99007,
148, 0.95211, 119, 0.99026, 160, 0.95023, 129, 0.99009, 171, 0.95157, 139, 0.99016, 183, 0.95162, 149, 0.99043, 196, 0.95054, 160, 0.99037, 209, 0.95036, 172, 0.99004, 222, 0.95096, 183, 0.99038, 236, 0.95053, 195, 0.99044, 250, 0.95085, 208, 0.99024, 265, 0.95024, 221, 0.99022,
280, 0.95034, 234, 0.99036, 295, 0.95108, 248, 0.99027, 311, 0.95096, 262, 0.99034, 328, 0.95006, 277, 0.99020, 344, 0.95115, 292, 0.99021, 362, 0.95013, 308, 0.99003, 379, 0.95099, 323, 0.99031, 397, 0.95111, 340, 0.99008, 416, 0.95057, 356, 0.99029, 435, 0.95055, 374, 0.99004,
454, 0.95103, 391, 0.99019, 474, 0.95088, 409, 0.99018, 495, 0.95014, 428, 0.99002, 515, 0.95092, 446, 0.99023, 537, 0.95011, 466, 0.99004, 558, 0.95074, 485, 0.99021, 580, 0.95082, 505, 0.99023, 603, 0.95037, 526, 0.99011, 626, 0.95035, 547, 0.99010, 649, 0.95072, 568, 0.99018,
673, 0.95060, 590, 0.99014, 698, 0.95002, 612, 0.99018, 722, 0.95064, 635, 0.99011, 748, 0.95000, 658, 0.99013, 773, 0.95052, 682, 0.99004, 799, 0.95059, 706, 0.99003, 826, 0.95025, 730, 0.99010, 853, 0.95025, 755, 0.99007, 880, 0.95056, 780, 0.99011, 908, 0.95048, 806, 0.99006,
937, 0.95003, 832, 0.99008, 965, 0.95057, 859, 0.99000, 995, 0.95007, 885, 0.99016, 1024, 0.95052, 913, 0.99007, 1054, 0.95060, 941, 0.99005, 1085, 0.95035, 969, 0.99009, 1116, 0.95038, 998, 0.99005, 1148, 0.95008, 1027, 0.99007, 1180, 0.95005, 1057, 0.99002, 1212, 0.95029, 1087, 0.99002,
1245, 0.95021, 1117, 0.99009, 1278, 0.95038, 1148, 0.99008, 1312, 0.95025, 1179, 0.99012, 1346, 0.95036, 1211, 0.99009, 1381, 0.95019, 1243, 0.99012, 1416, 0.95025, 1276, 0.99008, 1452, 0.95004, 1309, 0.99009, 1488, 0.95006, 1343, 0.99004, 1524, 0.95030, 1377, 0.99004, 1561, 0.95028, 1411, 0.99009,
1598, 0.95046, 1446, 0.99007, 1636, 0.95039, 1481, 0.99011, 1675, 0.95008, 1517, 0.99008, 1713, 0.95042, 1553, 0.99010, 1753, 0.95008, 1590, 0.99006, 1792, 0.95037, 1627, 0.99007, 1833, 0.95000, 1665, 0.99002, 1873, 0.95026, 1703, 0.99002, 1914, 0.95028, 1741, 0.99006, 1956, 0.95008, 1780, 0.99005,
1998, 0.95006, 1819, 0.99008, 2040, 0.95023, 1859, 0.99005, 2083, 0.95019, 1899, 0.99007, 2126, 0.95032, 1940, 0.99004, 2170, 0.95024, 1981, 0.99004, 2214, 0.95034, 2023, 0.99000, 2259, 0.95023, 2064, 0.99009, 2304, 0.95029, 2107, 0.99004, 2350, 0.95016, 2150, 0.99003, 2396, 0.95020, 2193, 0.99005,
2443, 0.95004, 2237, 0.99003, 2490, 0.95005, 2281, 0.99005, 2537, 0.95021, 2326, 0.99002, 2585, 0.95019, 2371, 0.99003, 2633, 0.95032, 2416, 0.99008, 2682, 0.95027, 2462, 0.99008, 2732, 0.95005, 2509, 0.99003, 2781, 0.95030, 2556, 0.99002, 2832, 0.95006, 2603, 0.99005, 2882, 0.95027, 2651, 0.99003,
2934, 0.95002, 2699, 0.99005, 2985, 0.95021, 2748, 0.99003, 3037, 0.95023, 2797, 0.99004, 3090, 0.95010, 2847, 0.99001, 3143, 0.95010, 2897, 0.99001, 3196, 0.95024, 2947, 0.99005, 3250, 0.95022, 2998, 0.99004, 3305, 0.95004, 3050, 0.99000, 3360, 0.95001, 3101, 0.99006, 3415, 0.95010, 3154, 0.99001,
3471, 0.95004, 3206, 0.99006, 3527, 0.95011, 3260, 0.99001, 3584, 0.95003, 3313, 0.99005, 3641, 0.95007, 3367, 0.99006, 3698, 0.95024, 3422, 0.99003, 3757, 0.95001, 3477, 0.99003, 3815, 0.95015, 3532, 0.99006, 3874, 0.95016, 3588, 0.99005, 3934, 0.95003, 3645, 0.99001, 3994, 0.95002, 3702, 0.99000,
4054, 0.95013, 3759, 0.99002, 4115, 0.95010, 3817, 0.99000, 4176, 0.95018, 3875, 0.99001, 4238, 0.95014, 3933, 0.99005, 4300, 0.95020, 3992, 0.99005, 4363, 0.95014, 4052, 0.99003, 4426, 0.95019, 4112, 0.99003, 4490, 0.95011, 4172, 0.99005, 4554, 0.95014, 4233, 0.99004, 4619, 0.95006, 4295, 0.99001,
4684, 0.95007, 4356, 0.99005, 4749, 0.95019, 4419, 0.99001, 4815, 0.95019, 4481, 0.99005, 4882, 0.95007, 4545, 0.99001, 4949, 0.95006, 4608, 0.99004, 5016, 0.95014, 4672, 0.99004, 5084, 0.95011, 4737, 0.99002, 5152, 0.95018, 4802, 0.99002, 5221, 0.95014, 4867, 0.99004, 5290, 0.95019, 4933, 0.99004,
5360, 0.95014, 5000, 0.99000, 5430, 0.95018, 5066, 0.99004, 5501, 0.95011, 5134, 0.99001, 5572, 0.95013, 5201, 0.99004, 5644, 0.95006, 5270, 0.99001, 5716, 0.95007, 5338, 0.99004, 5788, 0.95017, 5407, 0.99004, 5861, 0.95017, 5477, 0.99002, 5935, 0.95007, 5547, 0.99002, 6009, 0.95006, 5617, 0.99004,
6083, 0.95013, 5688, 0.99004, 6158, 0.95011, 5760, 0.99001, 6233, 0.95017, 5832, 0.99000, 6309, 0.95013, 5904, 0.99002, 6386, 0.95000, 5977, 0.99001, 6462, 0.95013, 6050, 0.99001, 6539, 0.95017, 6124, 0.99000, 6617, 0.95011, 6198, 0.99001, 6695, 0.95013, 6272, 0.99003, 6774, 0.95007, 6347, 0.99003,
6853, 0.95008, 6423, 0.99001, 6933, 0.95001, 6499, 0.99001, 7013, 0.95001, 6575, 0.99003, 7093, 0.95009, 6652, 0.99002, 7174, 0.95008, 6729, 0.99004, 7255, 0.95015, 6807, 0.99003, 7337, 0.95013, 6885, 0.99004, 7420, 0.95003, 6964, 0.99003, 7503, 0.95001, 7043, 0.99003, 7586, 0.95005, 7123, 0.99002,
7670, 0.95002, 7203, 0.99002, 7754, 0.95006, 7284, 0.99001, 7839, 0.95001, 7365, 0.99001, 7924, 0.95004, 7446, 0.99003, 8009, 0.95014, 7528, 0.99002, 8096, 0.95000, 7611, 0.99000, 8182, 0.95009, 7693, 0.99003, 8269, 0.95010, 7777, 0.99001, 8357, 0.95003, 7860, 0.99004, 8445, 0.95003, 7945, 0.99001,
8533, 0.95010, 8029, 0.99003, 8622, 0.95009, 8115, 0.99000, 8712, 0.95000, 8200, 0.99003, 8801, 0.95013, 8286, 0.99003, 8892, 0.95004, 8373, 0.99001, 8983, 0.95001, 8460, 0.99001, 9074, 0.95005, 8547, 0.99003, 9166, 0.95002, 8635, 0.99003, 9258, 0.95005, 8724, 0.99000, 9351, 0.95001, 8812, 0.99003,
9444, 0.95003, 8902, 0.99001, 9537, 0.95012, 8992, 0.99000, 9632, 0.95000, 9082, 0.99001, 9726, 0.95008, 9173, 0.99000, 9821, 0.95008, 9264, 0.99001, 9917, 0.95002, 9355, 0.99003, 10013, 0.95002, 9447, 0.99003, 10109, 0.95008, 9540, 0.99001, 10206, 0.95008, 9633, 0.99001, 10304, 0.95000, 9726, 0.99003,
10401, 0.95011, 9820, 0.99003, 10500, 0.95003, 9915, 0.99001, 10599, 0.95001, 10010, 0.99000, 10698, 0.95005, 10105, 0.99001, 10798, 0.95002, 10201, 0.99001, 10898, 0.95005, 10297, 0.99001, 10999, 0.95001, 10394, 0.99000, 11100, 0.95004, 10491, 0.99001, 11201, 0.95011, 10588, 0.99003, 11304, 0.95001, 10687, 0.99000,
11406, 0.95008, 10785, 0.99002, 11509, 0.95009, 10884, 0.99002, 11613, 0.95004, 10984, 0.99000, 11717, 0.95004, 11084, 0.99000, 11821, 0.95009, 11184, 0.99001, 11926, 0.95009, 11285, 0.99001, 12032, 0.95003, 11386, 0.99002, 12138, 0.95002, 11488, 0.99001, 12244, 0.95006, 11590, 0.99002, 12351, 0.95004, 11693, 0.99001,
12458, 0.95008, 11796, 0.99002, 12566, 0.95006, 11900, 0.99001, 12674, 0.95008, 12004, 0.99001, 12783, 0.95006, 12109, 0.99000, 12892, 0.95008, 12214, 0.99000, 13002, 0.95005, 12319, 0.99002, 13112, 0.95006, 12425, 0.99002, 13223, 0.95002, 12532, 0.99000, 13334, 0.95004, 12639, 0.99000, 13445, 0.95010, 12746, 0.99001,
13557, 0.95010, 12854, 0.99001, 13670, 0.95005, 12962, 0.99001, 13783, 0.95005, 13071, 0.99001, 13896, 0.95010, 13180, 0.99001, 14010, 0.95009, 13290, 0.99001, 14125, 0.95004, 13400, 0.99001, 14240, 0.95003, 13511, 0.99000, 14355, 0.95006, 13622, 0.99000, 14471, 0.95005, 13733, 0.99002, 14587, 0.95008, 13845, 0.99002)
//-->
</script>
</head>
<body bgcolor="#ffffff">
<font size="+2"><b>中央値の点推定値と信頼区間</b></font> <a href="src/median-conf.html"><img src="png/src.png" width=35 height=11 alt="src" align=top></a> Last modified: Jun 01, 2006<hr noshade><p>
<font color="#ff0000" size="+2">以下のプログラムのサポートは終了しました。自己責任でお使い下さい。</font>
<form name=Result>
<script language="JavaScript">
<!--
//-->JavaScript がサポートされていないブラウザですか?
</script>
<input type="button" name="calcurate" value="計算開始" onClick="calc(this.form.data.value)">
<input type="button" name="clear" value="入力欄クリア" onClick="this.form.data.value=''">
<input type="button" name="clear" value="出力欄クリア" onClick="this.form.result.value=''">
<p>
<table><tr>
<td>入力欄<br><textarea name="data" ROWS=25 COLS=15></textarea></td><td>出力欄<br><textarea name="result" ROWS=25 COLS=80></textarea></td>
</tr></table>
</form>
入力欄にデータを<a href="exa/kugirimoji.html">区切り文字</a>で区切って何行でも
<p><hr noshade>
<img src="../gra/button3.png" width=9 height=9 alt="・"> <a href="../LaTeX/median.pdf">手法の解説(pdf ファイル)</a><br>
<img src="../gra/button3.png" width=9 height=9 alt="・"> <A HREF="javascript:history.go(-1)">直前のページへ戻る</A> <img src="../gra/button3.png" width=9 height=9 alt="・"> <a href="../mail.html">E-mail to Shigenobu AOKI</a>
<p><center><IMG SRC="../gra/ume5.png" width=121 height=37 ALT="Made with Macintosh"></center>
</body>
</html>
サブ io.js Last modified: Mar 25, 2004
直前のページへ戻る E-mail to Shigenobu AOKI