Skip to content

Bernoulli Distribution

Esteban Zapata Rojas edited this page Jul 4, 2018 · 1 revision

Bernoulli Distribution

Class Methods

Density function

It returns the probability mass value for the specified n and p. Keep in mind that the support for the Bernoulli distribution is n = {0, 1}, so the function is not defined for values different than zero and one.

[36] pry(main)> Distribution::Bernoulli.density_function(1, 0.75)
=> 0.75
[37] pry(main)> Distribution::Bernoulli.density_function(0, 0.75)
=> 0.25
[38] pry(main)> Distribution::Bernoulli.density_function(3, 0.75)
=> nil
[39] pry(main)> Distribution::Bernoulli.density_function(-1, 0.75)
=> nil

Cumulative function

It returns the probability P(x <= N) for the specified N. Keep in mind that the support for the Bernoulli distribution is n = {0, 1}, so the function is not defined for values different than zero and one.

[40] pry(main)> Distribution::Bernoulli.cumulative_function(0, 0.75)
=> 0.25
[41] pry(main)> Distribution::Bernoulli.cumulative_function(1, 0.75)
=> 1.0
[42] pry(main)> Distribution::Bernoulli.cumulative_function(-1, 0.75)
=> nil
[43] pry(main)> Distribution::Bernoulli.cumulative_function(2, 0.75)
=> nil

Variance

It returns the expected variance for the bernoulli distribution with the specified probability.

[44] pry(main)> Distribution::Bernoulli.variance(0.75)
=> 0.1875

Skewness

It calculates the skewness for the bernoulli distribution with the specified probability.

[45] pry(main)> Distribution::Bernoulli.skewness(0.75)
=> -1.1547005383792517

Kurtosis

It calculates the kurtosis for the bernoulli distribution with the specified probability.

[46] pry(main)> Distribution::Bernoulli.kurtosis(0.75)
=> -0.6666666666666666