lib/distribution/t/ruby.rb in distribution-0.5.0 vs lib/distribution/t/ruby.rb in distribution-0.6.0
- old
+ new
@@ -13,10 +13,11 @@
# t-distribution ([1])
# (-\infty, x]
def p_t(df, t)
if df.to_i!=df
- raise "Can't calculate not integer df"
+ x=(t+Math.sqrt(t**2+df)) / (2*Math.sqrt(t**2+df))
+ return Math.regularized_beta(x,df/2.0,df/2.0)
end
df=df.to_i
c2 = df.to_f / (df + t * t);
s = Math.sqrt(1.0 - c2)
s = -s if t < 0.0
\ No newline at end of file