-
Notifications
You must be signed in to change notification settings - Fork 15
Continuous Uniform distribution
Esteban Zapata Rojas edited this page Oct 19, 2017
·
2 revisions
It calculates the probability P(x <= X)
for an specified X, based on the left/right values specified at initialization time. If the specified value X <= left, then the result is zero. If the specified value X >= right, it returns one.
[78] pry(main)> Distribution::Uniform.new(3,4)
=> #<Statistics::Distribution::Uniform:0x00000000019d4fd0 @left=3.0, @right=4.0>
[79] pry(main)> Distribution::Uniform.new(3,4).cumulative_function(2)
=> 0
[80] pry(main)> Distribution::Uniform.new(3,4).cumulative_function(3.5)
=> 0.5
[81] pry(main)> Distribution::Uniform.new(3,4).cumulative_function(5)
=> 1
Given an interval at initialize time, calculate the density for the specified value that belongs to the interval. If the value is outside the given internal, it returns zero.
[63] pry(main)> uniform_dist = Distribution::Uniform.new(3,6)
=> #<Statistics::Distribution::Uniform:0x007fdfcbe161c8 @left=3.0, @right=6.0>
[64] pry(main)> uniform_dist.density_function(4) # interval: [3, 6]
=> 0.3333333333333333
[65] pry(main)> uniform_dist.density_function(7) # interval: [3, 6]
=> 0
It returns the expected mean value for the uniform distribution.
[66] pry(main)> uniform_dist.mean
=> 4.5
It returns the expected variance value for the uniform distribution.
[67] pry(main)> uniform_dist.variance
=> 0.75