-
Notifications
You must be signed in to change notification settings - Fork 15
Beta Distribution
Esteban Zapata Rojas edited this page Jul 2, 2024
·
4 revisions
it returns the probability P(x <= X)
for an specified 0.0 <= X < 1. For values X >= 1 it returns 1.0.
Keep in mind that this function is just a wrapper around Math.incomplete_beta_function(alpha, beta, X)
.
21] pry(main)> Distribution::Beta.new(2,3)
=> #<Statistics::Distribution::Beta:0x0000000001a500b8 @alpha=2.0, @beta=3.0>
[22] pry(main)> Distribution::Beta.new(2,3).cumulative_function(0.5)
=> 0.6875
[23] pry(main)> Distribution::Beta.new(2,3).cumulative_function(1.0)
=> 1.0
[24] pry(main)> Distribution::Beta.new(2,3).cumulative_function(-1.0)
=> nil
It calculates the density for the specified value. If the value is greater than 1 or less than 0, it will default to zero.
[3] pry(main)> beta_distribution = RubyStatistics::Distribution::Beta.new(2, 2)
=> #<Statistics::Distribution::Beta:0x007fc30a5126b8 @alpha=2.0, @beta=2.0>
[4] pry(main)> results = [0, 0.2, 0.4, 0.6, 0.8, 1].map do |number|
[4] pry(main)* beta_distribution.density_function(number)
[4] pry(main)* end
=> [0.0, 0.9600000000000002, 1.44, 1.44, 0.9599999999999999, 0.0]
It returns the mode for the beta distribution. The mode is not defined for values of alpha <=1 && beta <=1
.
[35] pry(main)> beta_distribution
=> #<Statistics::Distribution::Beta:0x007fdfcb933610 @alpha=2.0, @beta=2.0>
[36] pry(main)> beta_distribution.mode
=> 0.5
[37] pry(main)> RubyStatistics::Distribution::Beta.new(0.5, 0.5).mode
=> nil
It returns the mean for the beta distribution.
[40] pry(main)> beta_distribution
=> #<Statistics::Distribution::Beta:0x007fdfcb933610 @alpha=2.0, @beta=2.0>
[41] pry(main)> beta_distribution.mean
=> 0.5
``