gleam_stats/distributions/chisquared

Functions related to continuous normal random variables.


Functions

pub fn chisquared_cdf(x: Float, ddof: Int) -> Result(
  Float,
  String,
)

Evaluate, at a certain point, the cumulative distribution function (cdf) of a continuous chi-squared random variable with given degrees of freedom ‘ddof’ > 0.

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

 pub fn example() {
   let ddof: Float = 1.
   // For illustrational purposes, evaluate the cdf at the 
   // point -100.0
   chisquared.chisquared_cdf(-100.0, mu, sigma) |> should.equal(Ok(0.0))
 }
pub fn chisquared_mean(ddof: Int) -> Result(Float, String)

Analytically compute the mean of a continuous chi-squared random variable
with given degrees of freedom ‘ddof’ > 0.

pub fn chisquared_pdf(x: Float, ddof: Int) -> Result(
  Float,
  String,
)

Evaluate the probability density function (pdf) of a continuous chi-squared random variable with given degrees of freedom ‘ddof’ > 0.

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

 pub fn example() {
   let ddof: Float = 1.
   // For illustrational purposes, evaluate the pdf at the 
   // point -100.0
   chisquared.chisquared_pdf(-100.0, ddof) |> should.equal(Ok(0.0))
 }
pub fn chisquared_random(stream: Iterator(Int), ddof: Int, m: Int) -> Result(
  #(List(Float), Iterator(Int)),
  String,
)

Generate ‘m’ random numbers from a continuous chi-squared distribution with given degrees of freedom ‘ddof’ > 0.

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

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

Analytically compute the variance of a continuous chi-squared random variable
with given degrees of freedom ‘ddof’ > 0.