メイン norm-fit1.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="gxp.js">document.write("gxp.js ファイルが見つかりません??<br>")</script>
<script src="xxp.js">document.write("xxp.js ファイルが見つかりません??<br>")</script>
<script src="io.js">document.write("io.js ファイルが見つかりません??<br>")</script>
<script language="JavaScript">
<!--
function calc(s, w, a, data_string)
{
var f = new Array()
var expectation = new Array()
var lines, nc, i, from, ulimit, center, mean, variance, n, sd, z, p, cum, tp, sum0, sum1, sum2, chi_sq, up, low, df, delimiter = ","
var start = parseFloat(s)
var width = parseFloat(w)
var accuracy = parseFloat(a)
if (data_string.indexOf(delimiter) == -1) {
if (data_string.indexOf("\t") != -1) {
delimiter = "\t"
}
else {
delimiter = " "
}
}
lines = data_string.split(delimiter)
nc = lines.length
for (i = 0; i < nc; i++) {
f[i+1] = parseFloat(lines[i])
if (isNaN(f[i+1]) || f[i+1] != Math.floor(f[i+1])) {
printf("入力数値が変です。%s\n", lines[i])
return
}
}
nc += 2
f[0] = f[nc-1] = 0
start -= width
n = mean = variance = 0
for (i = 0; i < nc; i++) {
center = (start+i*width)+width-accuracy/2-width/2
n += f[i]
mean += center*f[i]
variance += center*center*f[i]
}
mean /= n
variance = variance/n-mean*mean
sd = Math.sqrt(variance)
cum = sum1 = sum2 = sum0 = 0
printf("★ 正規分布へのあてはめ(面積を計算する方法) ★\n\n")
printf(" 平均値 = %.6g\n", mean)
printf(" 分散 = %.6g\n", variance)
printf("標準偏差 = %.6g\n\n", sd)
sep(56)
printf("%12s%10s%10s%10s%13s\n", "階級開始値", "観察度数", "相対度数", "理論比", "期待値")
sep(56)
for (i = 0; i < nc; i++) {
from = start+i*width
ulimit = from+width-accuracy/2
z = (ulimit-mean)/sd
p = (i == nc-1) ? 1 : 1-gxp(z)
tp = p-cum
cum = p
expectation[i] = n*tp
printf("%12.6g%10i%10.5f%10.5f%13.5f\n", from, f[i], f[i]/n, tp, expectation[i])
sum0 += f[i]/n
sum1 += tp
sum2 += expectation[i]
}
sep(56)
printf("%12s%10i%10.5f%10.5f%13.5f\n", "合計", n, sum0, sum1, sum2)
sep(56)
printf("\n")
chk = 0
for (low = 0; low < nc; low++) {
chk += expectation[low]
if (chk >= 1.0) break
}
chk = 0
for (up = nc-1; up >= 0; up--) {
chk += expectation[up]
if (chk >= 1.0) break
}
if (low != nc && up-low >= 3) {
printf("★ 適合度の検定 ★\n\n")
if (low > 0) {
printf("最初の %i カテゴリーを併合した\n", low+1)
}
for (i = 0; i < low; i++) {
expectation[low] += expectation[i]
f[low] += f[i]
}
if (up != nc -1) {
printf("最後の %i カテゴリーを併合した\n", nc-up)
}
for (i = up+1; i < nc; i++) {
expectation[up] += expectation[i]
f[up] += f[i]
}
chi_sq = 0
for (i = low; i <= up; i++) {
chi_sq += Math.pow(f[i]-expectation[i], 2.0)/expectation[i]
}
df = up-low-2
printf("カイ二乗値 = %.5f\n", chi_sq)
printf(" 自由度 = %i\n", df)
printf(" 有意確率 = %.5f\n\n", xxp(chi_sq, df))
}
sep2(60)
printf("\n\n")
}
//-->
</script>
</head>
<body bgcolor="#ffffff">
<font size="+2"><b>正規分布へのあてはめ(面積を計算する方法)</b></font> <a href="src/norm-fit1.html"><img src="png/src.png" width=35 height=11 alt="src" align=top></a><br> Last modified: Jun 01, 2006<hr noshade><p>
<font color="#ff0000" size="+2">以下のプログラムのサポートは終了しました。自己責任でお使い下さい。</font>
<form name=Result>
<script language="JavaScript">
<!--
//-->JavaScript がサポートされていないブラウザですか?
</script>
<table><tr>
<td><input type="button" name="calcurate" value="計算開始" onClick="calc(this.form.start.value, this.form.width.value, this.form.accuracy.value, this.form.data.value)"> </td>
<td><input type="button" name="clear" value="入力欄クリア" onClick="this.form.data.value=this.form.start.value=this.form.width.value=this.form.accuracy.value=''"> </td>
<td><input type="button" name="clear" value="出力欄クリア" onClick="this.form.result.value=''"> </td>
<td><img src="../gra/button3.png" width=9 height=9 alt="・"> <a href="exa/norm-fit.html">使用法</a></td>
</tr></table>
<p>
階級開始値 <input name="start" value="40" size=8>
階級幅 <input name="width" value="5" size=8>
測定精度 <input name="accuracy" value="0.1" size=8><br>
観察度数 <input name="data" size=70 value="4,19,86,177,105,33,2"><p>
出力欄<br><textarea name="result" ROWS=26 COLS=80></textarea>
</form>
<p><hr noshade>
<img src="../gra/button3.png" width=9 height=9 alt="・"> <a href="../lecture/Bunpu/normdist/atehame.html">手法の解説(1)</a> <img src="../gra/button3.png" width=9 height=9 alt="・"> <a href="../lecture/GoodnessOfFitness/normaldist.html">手法の解説(2)</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>
サブ gxp.js Last modified: Mar 25, 2004
サブ xxp.js Last modified: Mar 25, 2004
サブ io.js Last modified: Mar 25, 2004
直前のページへ戻る E-mail to Shigenobu AOKI