gleam_stats/distributions/weibull

Functions related to continuous weibull random variables.


Functions

pub fn weibull_cdf(x: Float, lambda: Float, k: Float) -> Result(
  Float,
  String,
)

Evaluate, at a certain point, the cumulative distribution function (cdf) of a weibull random variable with scale parameter ‘lambda’ > 0 and shape parameter ‘k’ > 0.

Example:
 import gleam_stats/distributions/weibull
 import gleeunit/should

 pub fn example() {
   let lambda: Float = 1.
   let k: Float = 5.
   // For illustrational purposes, evaluate the cdf at the 
   // point -100.0
   weibull.weibull_cdf(-100.0, lambda, k) |> should.equal(Ok(0.0))
 }
pub fn weibull_mean(lambda: Float, k: Float) -> Result(
  Float,
  String,
)

Analytically compute the mean of a continuous weibull random variable
with scale parameter ‘lambda’ > 0 and shape parameter ‘k’ > 0.

pub fn weibull_pdf(x: Float, lambda: Float, k: Float) -> Result(
  Float,
  String,
)

Evaluate the probability density function (pdf) of a continuous weibull random variable with scale parameter ‘lambda’ > 0 and shape parameter ‘k’ > 0.

Example:
 import gleam_stats/distributions/weibull
 import gleeunit/should

 pub fn example() {
   let lambda: Float = 1.
   let k: Float = 5.
   // For illustrational purposes, evaluate the pdf at the 
   // point -100.0
   weibull.weibull_pdf(-100.0, lambda, k) |> should.equal(Ok(0.0))
 }
pub fn weibull_random(stream: Iterator(Int), lambda: Float, k: Float, m: Int) -> Result(
  #(List(Float), Iterator(Int)),
  String,
)

Generate ‘m’ random numbers from a continuous weibull distribution with scale parameter ‘lambda’ > 0 and shape parameter ‘k’ > 0.

The random numbers are generated using the inverse transform method.

Example:
 import gleam/iterator.{Iterator}
 import gleam_stats/generator
 import gleam_stats/distributions/weibull

 pub fn example() {
   let seed: Int = 5
   let seq: Int = 1
   let lambda: Float = 1.
   let k: Float = 5.
   assert Ok(out) =
     generators.seed_pcg32(seed, seq)
     |> weibull.weibull_random(lambda, k, 5_000)
   let rands: List(Float) = pair.first(out)
   let stream: Iterator(Int) = pair.second(out)
 }
pub fn weibull_variance(lambda: Float, k: Float) -> Result(
  Float,
  String,
)

Analytically compute the variance of a continuous weibull random variable
with scale parameter ‘lambda’ > 0 and shape parameter ‘k’ > 0.