メイン tests.html   Last modified: Nov 10, 2006
<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="pxg.js">document.write("pxg.js ファイルが見つかりません??<br>")</script>
<script src="fxp.js">document.write("fxp.js ファイルが見つかりません??<br>")</script>
<script src="pxf.js">document.write("pxf.js ファイルが見つかりません??<br>")</script>
<script src="fixed.js">document.write("fixed.js ファイルが見つかりません??<br>")</script>
<script src="out_pvalue.js">document.write("out_pvalue.js ファイルが見つかりません??<br>")</script>

<script language="JavaScript">
<!--

function f_hiritu1(form)
{
  form.f.value = form.df1.value = form.df2.value = form.p.value = ""
  var n, r, pi, p0, nu1, nu2, f, p, z
  if (isNaN(n = parseInt(form.n.value)) || n != Math.floor(n) || isNaN(r = parseInt(form.r.value)) || r != Math.floor(r) || n <= 0 || r < 0 || r > n || isNaN(pi = parseFloat(form.pi.value)) || pi <= 0 || pi >= 1) return
  p = r/n
  if (p > pi) {
    nu1 = 2*(n-r+1)
    nu2 = 2*r
    f = nu2*(1-pi)/(nu1*pi)
    p0 = 2*fxp(f, nu1, nu2)
  }
  else if (p < pi) {
    nu1 = 2*(r+1)
    nu2 = 2*(n-r)
    f = nu2*pi/(nu1*(1-pi))
    p0 = 2*fxp(f, nu1, nu2)
  }
  else {
    alert("標本比率と母比率は全く等しいですね?")
    return
  }
  form.f.value = fixed(f, 5)
  form.df1.value = nu1
  form.df2.value = nu2
  form.p.value = out_pvalue(p0)
  z = Math.abs(p-pi)/Math.sqrt(pi*(1-pi)/n)
  p0 = 2*gxp(z)
  form.z.value = fixed(z, 5)
  form.p2.value = out_pvalue(p0)
}

function f_hiritu2(form)
{
  form.lcl.value = form.ucl.value = ""
  var n, r, p, conf, nu1, nu2, f, z, z2
  if (isNaN(n = parseInt(form.n.value)) || n != Math.floor(n) || isNaN(r = parseInt(form.r.value)) || r != Math.floor(r) || n <= 0 || r < 0 || r > n || isNaN(conf = parseFloat(form.conf.value)) || conf <= 0 || conf >= 1) return
  p = r/n
  conf = 1-conf
  if (r == 0)  {
    form.ucl.value = fixed(1-Math.pow(conf, 1/n), 5)
    form.lcl.value = 0
  }
  else if (r == n) {
    form.lcl.value = fixed(Math.pow(conf, 1/n), 5)
    form.ucl.value = 1
  }
  else {
    nu1 = 2*(n-r+1)
    nu2 = 2*r
    f = pxf(conf/2, nu1, nu2)
    form.lcl.value = fixed(nu2/(nu1*f+nu2), 5)
    nu1 = 2*(r+1)
    nu2 = 2*(n-r)
    f = pxf(conf/2, nu1, nu2)
    form.ucl.value = fixed(nu1*f/(nu1*f+nu2), 5)
  }
  z = pxg(conf/2)
  z2 = z*z
  form.lcl2.value = fixed(n/(n+z2)*(p+z2/2/n-z*Math.sqrt(p*(1-p)/n+z2/4/n/n)), 5)
  form.ucl2.value = fixed(n/(n+z2)*(p+z2/2/n+z*Math.sqrt(p*(1-p)/n+z2/4/n/n)), 5)
}

function f_hiritu3(form)
{
  form.z.value = form.p.value = ""
  var n1, r1, n2, r2, p1, p2, p, z
  if (isNaN(n1 = parseInt(form.n1.value)) || n1 != Math.floor(n1) || isNaN(r1 = parseInt(form.r1.value)) || r1 != Math.floor(r1) || n1 <= 0 || r1 < 0 || r1 > n1 || isNaN(n2 = parseInt(form.n2.value)) || n2 != Math.floor(n2) || isNaN(r2 = parseInt(form.r2.value)) || r2 != Math.floor(r2) || n2 <= 0 || r2 < 0 || r2 > n1 ) return

  p1 = r1/n1
  p2 = r2/n2
  p = (r1+r2)/(n1+n2)
  if (Math.abs(p1-p2) < (1/n1+1/n2)*0.5) {
    form.z.value = 0
    form.p.value = 1
  }
  else {
    form.z.value = z = fixed((Math.abs(p1-p2)-(1/n1+1/n2)*0.5)/Math.sqrt(p*(1-p)*(1/n1+1/n2)), 5)
    form.p.value = out_pvalue(gxp(z)*2)
  }
}
//-->
</script>
</head>

<body bgcolor="#ffffff">
<font size="+2"><b>比率の検定・推定</b></font> <a  href="src/tests.html"><img src="png/src.png" width=35 height=11 alt="src" align=top></a>     Last modified: May 15, 2002
<script language="JavaScript">
<!--
//-->JavaScript がサポートされていないブラウザですか?
</script>
<hr noshade>
<table border=1>
<tr>
  <td nowrap align=right valign=top bgcolor="#eecccc">
    <table border=0>
    <caption><font color="#5555aa"><b>母比率の検定</b></font></caption>
    <tr>
    <td nowrap align=right>
      <form name="hiritu1">
      標本サイズ <input name="n" value=20 size=10><br>
      陽性数 <input name="r" value=2 size=10><br>
      母比率 <input name="pi" value=0.03 size=10><br>
      <input type="button" name="clear" value="初期化" onClick="this.form.n.value=this.form.r.value=this.form.pi.value=this.form.f.value=this.form.df1.value=this.form.df2.value=this.form.p.value=this.form.z.value=this.form.p2.value=''"> <input type="button" name="calcurate" value="計算開始" onClick="f_hiritu1(this.form)"><br>
      F<sub>0</sub> <input name="f" value="" size=10><br>
      第 1 自由度 <input name="df1" value="" size=10><br>
      第 2 自由度 <input name="df2" value="" size=10><br>
      P 値 <input name="p" value="" size=10><p>
      正規分布による近似(参考)<br>
      Z<sub>0</sub> <input name="z" value="" size=10><br>
      P 値 <input name="p2" value="" size=10><br>
      </form>
      <img src="../gra/button3.png" width=9 height=9 alt="・"> <A HREF="../lecture/Hiritu/bohiritu-test.html">手法の解説</a><br>
    </td>
    </tr>
    </table>
  </td>

  <td nowrap align=right valign=top bgcolor="#eecccc">
    <table border=0>
    <caption><font color="#5555aa"><b>母比率の信頼区間</b></font></caption>
    <tr>
    <td nowrap align=right>
      <form name="hiritu2">
      標本サイズ <input name="n" value=500 size=10><br>
      陽性数 <input name="r" value=175 size=10><br>
      信頼率 <input name="conf" value=0.95 size=10><br>
      <input type="button" name="clear" value="初期化" onClick="this.form.n.value=this.form.r.value=this.form.conf.value=this.form.lcl.value=this.form.ucl.value=this.form.lcl2.value=this.form.ucl2.value=''"> <input type="button" name="calcurate" value="計算開始" onClick="f_hiritu2(this.form)"><br>
      下側信頼限界 <input name="lcl" value="" size=10><br>
      上側信頼限界 <input name="ucl" value="" size=10><p>
      正規分布による近似(参考)<br>
      下側信頼限界 <input name="lcl2" value="" size=10><br>
      上側信頼限界 <input name="ucl2" value="" size=10><br>
      </form>
      <img src="../gra/button3.png" width=9 height=9 alt="・"> <A HREF="../lecture/Hiritu/bohiritu-conf.html">手法の解説</a><br>
    </td>
    </tr>
    </table>
  </td>

  <td nowrap align=right valign=top bgcolor="#eecccc">
    <table border=0>
    <caption><font color="#5555aa"><b>二群の比率の差の検定</b></font></caption>
    <tr>
    <td nowrap align=right>
      <form name="hiritu3">
      第一群の標本サイズ <input name="n1" value=300 size=10><br>
      陽性数   <input name="r1" value=145 size=10><br>
      第二群の標本サイズ <input name="n2" value=250 size=10><br>
      陽性数   <input name="r2" value=157 size=10><br>
      <input type="button" name="clear" value="初期化" onClick="this.form.n1.value=this.form.r1.value=this.form.n2.value=this.form.r2.value=this.form.z.value=this.form.p.value=''"> <input type="button" name="calcurate" value="計算開始" onClick="f_hiritu3(this.form)"><br>
      連続性の補正 z<sub>0</sub> <input name="z" value="" size=10><br>
      P 値 <input name="p" value="" size=10><br>
      </form>
      <img src="../gra/button3.png" width=9 height=9 alt="・"> <A HREF="../lecture/Hiritu/diff-p-test.html">手法の解説</a><br>
    </td>
    </tr>
    </table>
  </td>
</tr>

</table>
<p><hr noshade>
<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
サブ fxp.js   Last modified: Mar 25, 2004
サブ pxf.js   Last modified: Mar 25, 2004
サブ fixed.js   Last modified: Mar 25, 2004
サブ out_pvalue.js   Last modified: Mar 25, 2004

・ 直前のページへ戻る  ・ E-mail to Shigenobu AOKI

Made with Macintosh