Skip to content

F Distribution

Esteban Zapata Rojas edited this page Oct 19, 2017 · 2 revisions

Instance methods

Cumulative function

It returns the probability P(x <= X) for an specified X. It uses the incomplete beta function to do the math.

[59] pry(main)> Distribution::F.new(3, 4).cumulative_function(2)
=> 0.7436128024708638

Probability density function

It returns the density for the specified value, according to the F distribution. If any of the degrees of freedom specified at initialize time is zero, the density is not defined.

[80] pry(main)> f_dist = Distribution::F.new(5, 2)
=> #<Statistics::Distribution::F:0x007fdfcbe84010 @d1=5, @d2=2>
[81] pry(main)> results = (0..5).map do |number|
[81] pry(main)*   f_dist.density_function(number)
[81] pry(main)* end  
=> [NaN, 0.3080008216940658, 0.13207044692929354, 0.07169777401493925, 0.04477190971288469, 0.030554617202959922]

Mean

It performs the expected calculation when the second degree of freedom is greater than two. In other cases it's not defined.

[85] pry(main)> f_dist.mean
=> nil
[86] pry(main)> Distribution::F.new(1, 3).mean
=> 3.0

Mode

It performs the expected calculation when the first degree of freedom is greater than two. In other cases, it's not defined.

[87] pry(main)> Distribution::F.new(1, 3).mode
=> nil
[88] pry(main)> f_dist.mode
=> 0.3
``