サブ pxf.js Last modified: Mar 25, 2004
// defined fxp
// defined pxt
// defined pxx
function pxf(p0, df1, df2)
{
var xl, xr, p9, temp, c, xm
var ok = 0
/* 二分法のための左右点を求める */
xl = 0.0
xr = 10.0
while (xr < 1e30) {
p9 = fxp(xr, df1, df2)
if (p9 == p0) {
return xr
}
else if (p9 < p0) {
ok = 1
break
}
xl = xr
xr *= 10.0
}
if (ok == 0) {
if (df1 > df2) {
temp = df1
df1 = df2
df2 = temp
p0 = 1.0-p0
ok = 1
}
if (df1 == 1) {
c = pxt(p0, df2)
c = c*c
}
else {
temp = df1-2.0
c = pxx(p0, df1)
c = c/df1*(1.0+ (c-temp)*0.5/df2 + (4.0*c*c-11.0*temp*c+temp*(7.0*df1-10.0))/(24.0*df2*df2)
+(2.0*c*c*c-10.0*temp*c*c+temp*(17.0*df1-26.0)*c-(df1-2)*temp*(9.0*df1-6.0))/(48.0*df2*df2*df2))
}
return (ok == 1 && c != 0.0) ? 1.0/c : c
}
/* 二分法によりパーセント点を求める */
for (;;) {
xm = (xl+xr)*0.5
p9 = fxp(xm, df1, df2)
if (p9 > p0) {
xl = xm
}
else {
xr = xm
}
if (Math.abs(xr-xl)/xm < 1e-10) break
}
return xm
}
直前のページへ戻る E-mail to Shigenobu AOKI