# Module: Distribution::F::Ruby_

Extended by:
MathExtension
Defined in:
lib/distribution/f/ruby.rb

## Overview

The upper and lower cumulative distribution functions are related by P(x) + Q(x) = 1 and satisfy 0 <= P(x) <= 1, 0 <= Q(x).

## Class Method Summary collapse

• Cumulative Distribution Function.

• Return the corresponding F value for a p-value `y` with `n` and `m` degrees of freedom.

• F Distribution (Ruby) -- Probability Density Function.

• Upper cumulative function.

• .quantile(probability, n, m) ⇒ Object (also: p_value)

Return the F value corresponding to `probability` with degrees of freedom `n` and `m`.

## Class Method Details

### .cdf(x, n, m) ⇒ Object

Cumulative Distribution Function.

 ``` 44 45 46 47 48``` ```# File 'lib/distribution/f/ruby.rb', line 44 def cdf(x, n, m) x = x.to_f xx = (x * n).to_f / (x * n + m).to_f regularized_beta(xx, n / 2.0, m / 2.0) end```

### .entropy ⇒ Object

 ``` 111 112``` ```# File 'lib/distribution/f/ruby.rb', line 111 def entropy end```

### .kurtosis ⇒ Object

 ``` 108 109``` ```# File 'lib/distribution/f/ruby.rb', line 108 def kurtosis end```

### .mean ⇒ Float

Return the corresponding F value for a p-value `y` with `n` and `m` degrees of freedom.

Parameters:

• y (Float)

Value corresponding to the desired p-value. Between 0 and 1.

• n (Float)

Degree of freedom of the first random variable.

• m (Float)

Degree of freedom of the second random variable.

Returns:

• (Float)

Value of the F distribution that gives a p-value of `y`.

 ``` 99 100``` ```# File 'lib/distribution/f/ruby.rb', line 99 def mean end```

### .mode ⇒ Object

 ``` 102 103``` ```# File 'lib/distribution/f/ruby.rb', line 102 def mode end```

### .pdf(x, n, m) ⇒ Object

F Distribution (Ruby) -- Probability Density Function

 ``` 35 36 37 38 39 40 41``` ```# File 'lib/distribution/f/ruby.rb', line 35 def pdf(x, n, m) x = x.to_f numerator = ((n * x)**n * (m**m)) / (n * x + m)**(n + m) denominator = x * Math.beta(n / 2.0, m / 2.0) Math.sqrt(numerator) / denominator end```

### .q(x, n, m) ⇒ Object

Upper cumulative function.

If cdf(x, n, m) = p, then q(x, n, m) = 1 - p

 ``` 53 54 55``` ```# File 'lib/distribution/f/ruby.rb', line 53 def q(x, n, m) 1.0 - cdf(x, n, m) end```

### .quantile(probability, n, m) ⇒ ObjectAlso known as: p_value

Return the F value corresponding to `probability` with degrees of freedom `n` and `m`.

If x = quantile(p, n, m), then cdf(x, n, m) = p.

 ``` 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81``` ```# File 'lib/distribution/f/ruby.rb', line 64 def quantile(probability, n, m) return Float::NAN if n <= 0.0 || m <= 0.0 if n == Float::INFINITY || n == -Float::INFINITY || m == Float::INFINITY || m == -Float::INFINITY return 1.0 end if n <= m && m > 4e5 return Distribution::ChiSquare.p_value(probability, n) / n.to_f elsif n > 4e5 # thus n > m return m.to_f / Distribution::ChiSquare.p_value(1.0 - probability, m) else # O problema estÃ¡ aqui. tmp = Distribution::Beta.p_value(1.0 - probability, m.to_f / 2, n.to_f / 2) value = (1.0 / tmp - 1.0) * (m.to_f / n.to_f) return value.nan? ? Float::NAN : value end end```

### .skewness ⇒ Object

 ``` 105 106``` ```# File 'lib/distribution/f/ruby.rb', line 105 def skewness end```