-
Notifications
You must be signed in to change notification settings - Fork 15
Weibull Distribution
Esteban Zapata Rojas edited this page Jan 18, 2018
·
2 revisions
It returns the probability P(x <= X)
for an specified X. If X < 0, then the probability is zero.
[85] pry(main)> Distribution::Weibull.new(2, 3)
=> #<Statistics::Distribution::Weibull:0x0000000001213170 @scale=3.0, @shape=2.0>
[86] pry(main)> Distribution::Weibull.new(2, 3).cumulative_function(-1)
=> 0
[87] pry(main)> Distribution::Weibull.new(2, 3).cumulative_function(5)
=> 0.9378234759778837
It returns the probability density value for the specified X. If X < 0, then the returned value is zero. If the scale or the shape defined at initialization time is <= 0, then the function is not defined.
[93] pry(main)> Distribution::Weibull.new(2, 0).density_function(3)
=> nil
[94] pry(main)> Distribution::Weibull.new(0, 2).density_function(3)
=> nil
[95] pry(main)> Distribution::Weibull.new(2, 2).density_function(-3)
=> 0
[96] pry(main)> Distribution::Weibull.new(2, 2).density_function(3)
=> 0.1580988368427965
It returns the mean based on the specified scale and shape values.
[97] pry(main)> Distribution::Weibull.new(2, 2).mean
=> 1.772453850905516
[98] pry(main)> Distribution::Weibull.new(2, 3).mean
=> 2.658680776358274
It returns the variance based on the specified scale and shape values.
[99] pry(main)> Distribution::Weibull.new(2, 2).variance
=> 0.8584073464102064
[100] pry(main)> Distribution::Weibull.new(2, 3).variance
=> 1.9314165294229646
It returns the mode based on the specified scale and shape values.
[101] pry(main)> Distribution::Weibull.new(2, 2).mode
=> 1.4142135623730951
[102] pry(main)> Distribution::Weibull.new(2, 3).mode
=> 2.121320343559643
It returns a random number/sample following a Weibull distribution. You can pass two arguments:
-
elements: #
where#
is the size of the random sample to be generated. If not specified,1
by default. -
seed: #
where#
is any number to be used as a seed generator. If not specified,Random.new_seed
by default.
> weibull = Distribution::Weibull.new(5.0, 2.0)
=> #<Statistics::Distribution::Weibull:0x0000000124dbb8 @shape=5.0, @scale=2.0>
> weibull.random
=> 0.672463184666854
> weibull.random(elements: 3)
=> [0.9465663642766572, 0.500698386530963, 0.8171442176078962]
> weibull.random(seed: Random.new_seed)
=> 0.6904028173180309