From 93aa8a704525de6793c9b9b15687a2d9ea0d6287 Mon Sep 17 00:00:00 2001 From: Orion Yeung <11580988+orionyeung001@users.noreply.github.com> Date: Sun, 24 Mar 2024 16:37:34 -0500 Subject: [PATCH 1/7] doc: fix 0.16 changelog to include version dependency change rely on docs.rs to have correct versino in url for docs --- CHANGELOG.md | 4 ++++ Cargo.toml | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a65a3c75..9b8b7ffc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,13 @@ +Unreleased + + v0.16.0 - Adds an `sf` method to the `ContinuousCDF` and `DiscreteCDF` traits - Calculates the survival function (CDF complement) for the distribution. - Survival function implemented for all distributions implementing `ContinuousCDF` and `DiscreteCDF` - See [PR description](https://github.com/statrs-dev/statrs/pull/172) for in-depth changes +- update `nalgebra` to `0.29` v0.15.0 diff --git a/Cargo.toml b/Cargo.toml index c7ad536d..34549647 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,6 @@ description = "Statistical computing library for Rust" license = "MIT" keywords = ["probability", "statistics", "stats", "distribution", "math"] categories = ["science"] -documentation = "https://docs.rs/statrs/0.15.0/statrs/" homepage = "https://github.com/statrs-dev/statrs" repository = "https://github.com/statrs-dev/statrs" edition = "2018" From 9e7e0324bb3090512dcb6d9c9c41e26023234110 Mon Sep 17 00:00:00 2001 From: Orion Yeung <11580988+orionyeung001@users.noreply.github.com> Date: Thu, 14 Mar 2024 18:54:54 -0500 Subject: [PATCH 2/7] doc: docstrings with math now use text instead of ignore --- src/distribution/bernoulli.rs | 24 ++++++++++----------- src/distribution/beta.rs | 22 +++++++++---------- src/distribution/binomial.rs | 24 ++++++++++----------- src/distribution/categorical.rs | 20 +++++++++--------- src/distribution/cauchy.rs | 18 ++++++++-------- src/distribution/chi.rs | 22 +++++++++---------- src/distribution/chi_squared.rs | 24 ++++++++++----------- src/distribution/dirac.rs | 14 ++++++------- src/distribution/dirichlet.rs | 16 +++++++------- src/distribution/discrete_uniform.rs | 18 ++++++++-------- src/distribution/erlang.rs | 22 +++++++++---------- src/distribution/exponential.rs | 24 ++++++++++----------- src/distribution/fisher_snedecor.rs | 20 +++++++++--------- src/distribution/gamma.rs | 22 +++++++++---------- src/distribution/geometric.rs | 24 ++++++++++----------- src/distribution/hypergeometric.rs | 22 +++++++++---------- src/distribution/inverse_gamma.rs | 22 +++++++++---------- src/distribution/laplace.rs | 28 ++++++++++++------------- src/distribution/log_normal.rs | 28 ++++++++++++------------- src/distribution/multinomial.rs | 10 ++++----- src/distribution/multivariate_normal.rs | 10 +++++---- src/distribution/negative_binomial.rs | 24 ++++++++++----------- src/distribution/normal.rs | 28 ++++++++++++------------- src/distribution/pareto.rs | 24 ++++++++++----------- src/distribution/poisson.rs | 24 ++++++++++----------- src/distribution/students_t.rs | 24 ++++++++++----------- src/distribution/triangular.rs | 20 +++++++++--------- src/distribution/uniform.rs | 20 +++++++++--------- src/distribution/weibull.rs | 24 ++++++++++----------- 29 files changed, 312 insertions(+), 310 deletions(-) diff --git a/src/distribution/bernoulli.rs b/src/distribution/bernoulli.rs index e31f9c5f..46648a7a 100644 --- a/src/distribution/bernoulli.rs +++ b/src/distribution/bernoulli.rs @@ -92,7 +92,7 @@ impl DiscreteCDF for Bernoulli { /// /// # Formula /// - /// ```ignore + /// ```text /// if x < 0 { 0 } /// else if x >= 1 { 1 } /// else { 1 - p } @@ -106,7 +106,7 @@ impl DiscreteCDF for Bernoulli { /// /// # Formula /// - /// ```ignore + /// ```text /// if x < 0 { 1 } /// else if x >= 1 { 0 } /// else { p } @@ -123,7 +123,7 @@ impl Min for Bernoulli { /// /// # Formula /// - /// ```ignore + /// ```text /// 0 /// ``` fn min(&self) -> u64 { @@ -138,7 +138,7 @@ impl Max for Bernoulli { /// /// # Formula /// - /// ```ignore + /// ```text /// 1 /// ``` fn max(&self) -> u64 { @@ -152,7 +152,7 @@ impl Distribution for Bernoulli { /// /// # Formula /// - /// ```ignore + /// ```text /// p /// ``` fn mean(&self) -> Option { @@ -163,7 +163,7 @@ impl Distribution for Bernoulli { /// /// # Formula /// - /// ```ignore + /// ```text /// p * (1 - p) /// ``` fn variance(&self) -> Option { @@ -174,7 +174,7 @@ impl Distribution for Bernoulli { /// /// # Formula /// - /// ```ignore + /// ```text /// q = (1 - p) /// -q * ln(q) - p * ln(p) /// ``` @@ -186,7 +186,7 @@ impl Distribution for Bernoulli { /// /// # Formula /// - /// ```ignore + /// ```text /// q = (1 - p) /// (1 - 2p) / sqrt(p * q) /// ``` @@ -201,7 +201,7 @@ impl Median for Bernoulli { /// /// # Formula /// - /// ```ignore + /// ```text /// if p < 0.5 { 0 } /// else if p > 0.5 { 1 } /// else { 0.5 } @@ -216,7 +216,7 @@ impl Mode> for Bernoulli { /// /// # Formula /// - /// ```ignore + /// ```text /// if p < 0.5 { 0 } /// else { 1 } /// ``` @@ -231,7 +231,7 @@ impl Discrete for Bernoulli { /// /// # Formula /// - /// ```ignore + /// ```text /// if x == 0 { 1 - p } /// else { p } /// ``` @@ -244,7 +244,7 @@ impl Discrete for Bernoulli { /// /// # Formula /// - /// ```ignore + /// ```text /// else if x == 0 { ln(1 - p) } /// else { ln(p) } /// ``` diff --git a/src/distribution/beta.rs b/src/distribution/beta.rs index 6dd5adc3..ba071dfa 100644 --- a/src/distribution/beta.rs +++ b/src/distribution/beta.rs @@ -103,7 +103,7 @@ impl ContinuousCDF for Beta { /// /// # Formula /// - /// ```ignore + /// ```text /// I_x(α, β) /// ``` /// @@ -134,7 +134,7 @@ impl ContinuousCDF for Beta { /// /// # Formula /// - /// ```ignore + /// ```text /// I_(1-x)(β, α) /// ``` /// @@ -168,7 +168,7 @@ impl Min for Beta { /// /// # Formula /// - /// ```ignore + /// ```text /// 0 /// ``` fn min(&self) -> f64 { @@ -183,7 +183,7 @@ impl Max for Beta { /// /// # Formula /// - /// ```ignore + /// ```text /// 1 /// ``` fn max(&self) -> f64 { @@ -196,7 +196,7 @@ impl Distribution for Beta { /// /// # Formula /// - /// ```ignore + /// ```text /// α / (α + β) /// ``` /// @@ -215,7 +215,7 @@ impl Distribution for Beta { /// /// # Formula /// - /// ```ignore + /// ```text /// (α * β) / ((α + β)^2 * (α + β + 1)) /// ``` /// @@ -235,7 +235,7 @@ impl Distribution for Beta { /// /// # Formula /// - /// ```ignore + /// ```text /// ln(B(α, β)) - (α - 1)ψ(α) - (β - 1)ψ(β) + (α + β - 2)ψ(α + β) /// ``` /// @@ -256,7 +256,7 @@ impl Distribution for Beta { /// /// # Formula /// - /// ```ignore + /// ```text /// 2(β - α) * sqrt(α + β + 1) / ((α + β + 2) * sqrt(αβ)) /// ``` /// @@ -290,7 +290,7 @@ impl Mode> for Beta { /// /// # Formula /// - /// ```ignore + /// ```text /// (α - 1) / (α + β - 2) /// ``` /// @@ -314,7 +314,7 @@ impl Continuous for Beta { /// /// # Formula /// - /// ```ignore + /// ```text /// let B(α, β) = Γ(α)Γ(β)/Γ(α + β) /// /// x^(α - 1) * (1 - x)^(β - 1) / B(α, β) @@ -352,7 +352,7 @@ impl Continuous for Beta { /// /// # Formula /// - /// ```ignore + /// ```text /// let B(α, β) = Γ(α)Γ(β)/Γ(α + β) /// /// ln(x^(α - 1) * (1 - x)^(β - 1) / B(α, β)) diff --git a/src/distribution/binomial.rs b/src/distribution/binomial.rs index 85ddecaa..7c5c9622 100644 --- a/src/distribution/binomial.rs +++ b/src/distribution/binomial.rs @@ -106,7 +106,7 @@ impl DiscreteCDF for Binomial { /// /// # Formula /// - /// ```ignore + /// ```text /// I_(1 - p)(n - x, 1 + x) /// ``` /// @@ -125,7 +125,7 @@ impl DiscreteCDF for Binomial { /// /// # Formula /// - /// ```ignore + /// ```text /// I_(p)(x + 1, n - x) /// ``` /// @@ -147,7 +147,7 @@ impl Min for Binomial { /// /// # Formula /// - /// ```ignore + /// ```text /// 0 /// ``` fn min(&self) -> u64 { @@ -162,7 +162,7 @@ impl Max for Binomial { /// /// # Formula /// - /// ```ignore + /// ```text /// n /// ``` fn max(&self) -> u64 { @@ -175,7 +175,7 @@ impl Distribution for Binomial { /// /// # Formula /// - /// ```ignore + /// ```text /// p * n /// ``` fn mean(&self) -> Option { @@ -185,7 +185,7 @@ impl Distribution for Binomial { /// /// # Formula /// - /// ```ignore + /// ```text /// n * p * (1 - p) /// ``` fn variance(&self) -> Option { @@ -195,7 +195,7 @@ impl Distribution for Binomial { /// /// # Formula /// - /// ```ignore + /// ```text /// (1 / 2) * ln (2 * π * e * n * p * (1 - p)) /// ``` fn entropy(&self) -> Option { @@ -213,7 +213,7 @@ impl Distribution for Binomial { /// /// # Formula /// - /// ```ignore + /// ```text /// (1 - 2p) / sqrt(n * p * (1 - p))) /// ``` fn skewness(&self) -> Option { @@ -226,7 +226,7 @@ impl Median for Binomial { /// /// # Formula /// - /// ```ignore + /// ```text /// floor(n * p) /// ``` fn median(&self) -> f64 { @@ -239,7 +239,7 @@ impl Mode> for Binomial { /// /// # Formula /// - /// ```ignore + /// ```text /// floor((n + 1) * p) /// ``` fn mode(&self) -> Option { @@ -260,7 +260,7 @@ impl Discrete for Binomial { /// /// # Formula /// - /// ```ignore + /// ```text /// (n choose k) * p^k * (1 - p)^(n - k) /// ``` fn pmf(&self, x: u64) -> f64 { @@ -291,7 +291,7 @@ impl Discrete for Binomial { /// /// # Formula /// - /// ```ignore + /// ```text /// ln((n choose k) * p^k * (1 - p)^(n - k)) /// ``` fn ln_pmf(&self, x: u64) -> f64 { diff --git a/src/distribution/categorical.rs b/src/distribution/categorical.rs index f489d653..ba3c39de 100644 --- a/src/distribution/categorical.rs +++ b/src/distribution/categorical.rs @@ -89,7 +89,7 @@ impl DiscreteCDF for Categorical { /// /// # Formula /// - /// ```ignore + /// ```text /// sum(p_j) from 0..x /// ``` /// @@ -107,7 +107,7 @@ impl DiscreteCDF for Categorical { /// /// # Formula /// - /// ```ignore + /// ```text /// [ sum(p_j) from x..end ] /// ``` fn sf(&self, x: u64) -> f64 { @@ -128,7 +128,7 @@ impl DiscreteCDF for Categorical { /// /// # Formula /// - /// ```ignore + /// ```text /// i /// ``` /// @@ -151,7 +151,7 @@ impl Min for Categorical { /// /// # Formula /// - /// ```ignore + /// ```text /// 0 /// ``` fn min(&self) -> u64 { @@ -166,7 +166,7 @@ impl Max for Categorical { /// /// # Formula /// - /// ```ignore + /// ```text /// n /// ``` fn max(&self) -> u64 { @@ -179,7 +179,7 @@ impl Distribution for Categorical { /// /// # Formula /// - /// ```ignore + /// ```text /// Σ(j * p_j) /// ``` /// @@ -198,7 +198,7 @@ impl Distribution for Categorical { /// /// # Formula /// - /// ```ignore + /// ```text /// Σ(p_j * (j - μ)^2) /// ``` /// @@ -221,7 +221,7 @@ impl Distribution for Categorical { /// /// # Formula /// - /// ```ignore + /// ```text /// -Σ(p_j * ln(p_j)) /// ``` /// @@ -243,7 +243,7 @@ impl Median for Categorical { /// /// # Formula /// - /// ```ignore + /// ```text /// CDF^-1(0.5) /// ``` fn median(&self) -> f64 { @@ -257,7 +257,7 @@ impl Discrete for Categorical { /// /// # Formula /// - /// ```ignore + /// ```text /// p_x /// ``` fn pmf(&self, x: u64) -> f64 { diff --git a/src/distribution/cauchy.rs b/src/distribution/cauchy.rs index e42919ea..dcd81af5 100644 --- a/src/distribution/cauchy.rs +++ b/src/distribution/cauchy.rs @@ -91,7 +91,7 @@ impl ContinuousCDF for Cauchy { /// /// # Formula /// - /// ```ignore + /// ```text /// (1 / π) * arctan((x - x_0) / γ) + 0.5 /// ``` /// @@ -105,7 +105,7 @@ impl ContinuousCDF for Cauchy { /// /// # Formula /// - /// ```ignore + /// ```text /// (1 / π) * arctan(-(x - x_0) / γ) + 0.5 /// ``` /// @@ -123,7 +123,7 @@ impl Min for Cauchy { /// /// # Formula /// - /// ```ignore + /// ```text /// NEG_INF /// ``` fn min(&self) -> f64 { @@ -137,7 +137,7 @@ impl Max for Cauchy { /// /// # Formula /// - /// ```ignore + /// ```text /// INF /// ``` fn max(&self) -> f64 { @@ -150,7 +150,7 @@ impl Distribution for Cauchy { /// /// # Formula /// - /// ```ignore + /// ```text /// ln(γ) + ln(4π) /// ``` /// @@ -165,7 +165,7 @@ impl Median for Cauchy { /// /// # Formula /// - /// ```ignore + /// ```text /// x_0 /// ``` /// @@ -180,7 +180,7 @@ impl Mode> for Cauchy { /// /// # Formula /// - /// ```ignore + /// ```text /// x_0 /// ``` /// @@ -196,7 +196,7 @@ impl Continuous for Cauchy { /// /// # Formula /// - /// ```ignore + /// ```text /// 1 / (πγ * (1 + ((x - x_0) / γ)^2)) /// ``` /// @@ -212,7 +212,7 @@ impl Continuous for Cauchy { /// /// # Formula /// - /// ```ignore + /// ```text /// ln(1 / (πγ * (1 + ((x - x_0) / γ)^2))) /// ``` /// diff --git a/src/distribution/chi.rs b/src/distribution/chi.rs index 7fcccf5e..0a65a8e6 100644 --- a/src/distribution/chi.rs +++ b/src/distribution/chi.rs @@ -84,7 +84,7 @@ impl ContinuousCDF for Chi { /// /// # Formula /// - /// ```ignore + /// ```text /// P(k / 2, x^2 / 2) /// ``` /// @@ -105,7 +105,7 @@ impl ContinuousCDF for Chi { /// /// # Formula /// - /// ```ignore + /// ```text /// P(k / 2, x^2 / 2) /// ``` /// @@ -128,7 +128,7 @@ impl Min for Chi { /// /// # Formula /// - /// ```ignore + /// ```text /// 0 /// ``` fn min(&self) -> f64 { @@ -142,7 +142,7 @@ impl Max for Chi { /// /// # Formula /// - /// ```ignore + /// ```text /// INF /// ``` fn max(&self) -> f64 { @@ -159,7 +159,7 @@ impl Distribution for Chi { /// /// # Formula /// - /// ```ignore + /// ```text /// sqrt2 * Γ((k + 1) / 2) / Γ(k / 2) /// ``` /// @@ -193,7 +193,7 @@ impl Distribution for Chi { /// /// # Formula /// - /// ```ignore + /// ```text /// k - μ^2 /// ``` /// @@ -211,7 +211,7 @@ impl Distribution for Chi { /// /// # Formula /// - /// ```ignore + /// ```text /// ln(Γ(k / 2)) + 0.5 * (k - ln2 - (k - 1) * ψ(k / 2)) /// ``` /// @@ -236,7 +236,7 @@ impl Distribution for Chi { /// /// # Formula /// - /// ```ignore + /// ```text /// (μ / σ^3) * (1 - 2σ^2) /// ``` /// where `μ` is the mean and `σ` the standard deviation @@ -257,7 +257,7 @@ impl Mode> for Chi { /// /// # Formula /// - /// ```ignore + /// ```text /// sqrt(k - 1) /// ``` /// @@ -276,7 +276,7 @@ impl Continuous for Chi { /// /// # Formula /// - /// ```ignore + /// ```text /// (2^(1 - (k / 2)) * x^(k - 1) * e^(-x^2 / 2)) / Γ(k / 2) /// ``` /// @@ -299,7 +299,7 @@ impl Continuous for Chi { /// /// # Formula /// - /// ```ignore + /// ```text /// ln((2^(1 - (k / 2)) * x^(k - 1) * e^(-x^2 / 2)) / Γ(k / 2)) /// ``` fn ln_pdf(&self, x: f64) -> f64 { diff --git a/src/distribution/chi_squared.rs b/src/distribution/chi_squared.rs index 05ad63ba..5551b55f 100644 --- a/src/distribution/chi_squared.rs +++ b/src/distribution/chi_squared.rs @@ -108,7 +108,7 @@ impl ContinuousCDF for ChiSquared { /// /// # Formula /// - /// ```ignore + /// ```text /// (1 / Γ(k / 2)) * γ(k / 2, x / 2) /// ``` /// @@ -123,7 +123,7 @@ impl ContinuousCDF for ChiSquared { /// /// # Formula /// - /// ```ignore + /// ```text /// (1 / Γ(k / 2)) * γ(k / 2, x / 2) /// ``` /// @@ -141,7 +141,7 @@ impl Min for ChiSquared { /// /// # Formula /// - /// ```ignore + /// ```text /// 0 /// ``` fn min(&self) -> f64 { @@ -156,7 +156,7 @@ impl Max for ChiSquared { /// /// # Formula /// - /// ```ignore + /// ```text /// INF /// ``` fn max(&self) -> f64 { @@ -169,7 +169,7 @@ impl Distribution for ChiSquared { /// /// # Formula /// - /// ```ignore + /// ```text /// k /// ``` /// @@ -181,7 +181,7 @@ impl Distribution for ChiSquared { /// /// # Formula /// - /// ```ignore + /// ```text /// 2k /// ``` /// @@ -193,7 +193,7 @@ impl Distribution for ChiSquared { /// /// # Formula /// - /// ```ignore + /// ```text /// (k / 2) + ln(2 * Γ(k / 2)) + (1 - (k / 2)) * ψ(k / 2) /// ``` /// @@ -206,7 +206,7 @@ impl Distribution for ChiSquared { /// /// # Formula /// - /// ```ignore + /// ```text /// sqrt(8 / k) /// ``` /// @@ -221,7 +221,7 @@ impl Median for ChiSquared { /// /// # Formula /// - /// ```ignore + /// ```text /// k * (1 - (2 / 9k))^3 /// ``` fn median(&self) -> f64 { @@ -241,7 +241,7 @@ impl Mode> for ChiSquared { /// /// # Formula /// - /// ```ignore + /// ```text /// k - 2 /// ``` /// @@ -257,7 +257,7 @@ impl Continuous for ChiSquared { /// /// # Formula /// - /// ```ignore + /// ```text /// 1 / (2^(k / 2) * Γ(k / 2)) * x^((k / 2) - 1) * e^(-x / 2) /// ``` /// @@ -271,7 +271,7 @@ impl Continuous for ChiSquared { /// /// # Formula /// - /// ```ignore + /// ```text /// ln(1 / (2^(k / 2) * Γ(k / 2)) * x^((k / 2) - 1) * e^(-x / 2)) /// ``` fn ln_pdf(&self, x: f64) -> f64 { diff --git a/src/distribution/dirac.rs b/src/distribution/dirac.rs index b58b676b..daa081a2 100644 --- a/src/distribution/dirac.rs +++ b/src/distribution/dirac.rs @@ -85,7 +85,7 @@ impl Min for Dirac { /// /// # Formula /// - /// ```ignore + /// ```text /// v /// ``` fn min(&self) -> f64 { @@ -99,7 +99,7 @@ impl Max for Dirac { /// /// # Formula /// - /// ```ignore + /// ```text /// v /// ``` fn max(&self) -> f64 { @@ -121,7 +121,7 @@ impl Distribution for Dirac { /// /// # Formula /// - /// ```ignore + /// ```text /// 0 /// ``` /// @@ -133,7 +133,7 @@ impl Distribution for Dirac { /// /// # Formula /// - /// ```ignore + /// ```text /// 0 /// ``` /// @@ -145,7 +145,7 @@ impl Distribution for Dirac { /// /// # Formula /// - /// ```ignore + /// ```text /// 0 /// ``` fn skewness(&self) -> Option { @@ -158,7 +158,7 @@ impl Median for Dirac { /// /// # Formula /// - /// ```ignore + /// ```text /// v /// ``` /// @@ -173,7 +173,7 @@ impl Mode> for Dirac { /// /// # Formula /// - /// ```ignore + /// ```text /// v /// ``` /// diff --git a/src/distribution/dirichlet.rs b/src/distribution/dirichlet.rs index 104a5981..a08b3175 100644 --- a/src/distribution/dirichlet.rs +++ b/src/distribution/dirichlet.rs @@ -111,13 +111,13 @@ impl Dirichlet { /// /// # Formula /// - /// ```ignore + /// ```text /// ln(B(α)) - (K - α_0)ψ(α_0) - Σ((α_i - 1)ψ(α_i)) /// ``` /// /// where /// - /// ```ignore + /// ```text /// B(α) = Π(Γ(α_i)) / Γ(Σ(α_i)) /// ``` /// @@ -158,7 +158,7 @@ impl MeanN> for Dirichlet { /// /// # Formula /// - /// ```ignore + /// ```text /// α_i / α_0 /// ``` /// @@ -175,7 +175,7 @@ impl VarianceN> for Dirichlet { /// /// # Formula /// - /// ```ignore + /// ```text /// (α_i * (α_0 - α_i)) / (α_0^2 * (α_0 + 1)) /// ``` /// @@ -215,13 +215,13 @@ impl<'a> Continuous<&'a DVector, f64> for Dirichlet { /// /// # Formula /// - /// ```ignore + /// ```text /// (1 / B(α)) * Π(x_i^(α_i - 1)) /// ``` /// /// where /// - /// ```ignore + /// ```text /// B(α) = Π(Γ(α_i)) / Γ(Σ(α_i)) /// ``` /// @@ -249,13 +249,13 @@ impl<'a> Continuous<&'a DVector, f64> for Dirichlet { /// /// # Formula /// - /// ```ignore + /// ```text /// ln((1 / B(α)) * Π(x_i^(α_i - 1))) /// ``` /// /// where /// - /// ```ignore + /// ```text /// B(α) = Π(Γ(α_i)) / Γ(Σ(α_i)) /// ``` /// diff --git a/src/distribution/discrete_uniform.rs b/src/distribution/discrete_uniform.rs index c151318f..926b1cf3 100644 --- a/src/distribution/discrete_uniform.rs +++ b/src/distribution/discrete_uniform.rs @@ -63,7 +63,7 @@ impl DiscreteCDF for DiscreteUniform { /// /// # Formula /// - /// ```ignore + /// ```text /// (floor(x) - min + 1) / (max - min + 1) /// ``` fn cdf(&self, x: i64) -> f64 { @@ -131,7 +131,7 @@ impl Distribution for DiscreteUniform { /// /// # Formula /// - /// ```ignore + /// ```text /// (min + max) / 2 /// ``` fn mean(&self) -> Option { @@ -141,7 +141,7 @@ impl Distribution for DiscreteUniform { /// /// # Formula /// - /// ```ignore + /// ```text /// ((max - min + 1)^2 - 1) / 12 /// ``` fn variance(&self) -> Option { @@ -152,7 +152,7 @@ impl Distribution for DiscreteUniform { /// /// # Formula /// - /// ```ignore + /// ```text /// ln(max - min + 1) /// ``` fn entropy(&self) -> Option { @@ -163,7 +163,7 @@ impl Distribution for DiscreteUniform { /// /// # Formula /// - /// ```ignore + /// ```text /// 0 /// ``` fn skewness(&self) -> Option { @@ -176,7 +176,7 @@ impl Median for DiscreteUniform { /// /// # Formula /// - /// ```ignore + /// ```text /// (max + min) / 2 /// ``` fn median(&self) -> f64 { @@ -194,7 +194,7 @@ impl Mode> for DiscreteUniform { /// /// # Formula /// - /// ```ignore + /// ```text /// N/A // (max + min) / 2 for the middle element /// ``` fn mode(&self) -> Option { @@ -212,7 +212,7 @@ impl Discrete for DiscreteUniform { /// /// # Formula /// - /// ```ignore + /// ```text /// 1 / (max - min + 1) /// ``` fn pmf(&self, x: i64) -> f64 { @@ -232,7 +232,7 @@ impl Discrete for DiscreteUniform { /// /// # Formula /// - /// ```ignore + /// ```text /// ln(1 / (max - min + 1)) /// ``` fn ln_pmf(&self, x: i64) -> f64 { diff --git a/src/distribution/erlang.rs b/src/distribution/erlang.rs index 619ba698..e07dff6b 100644 --- a/src/distribution/erlang.rs +++ b/src/distribution/erlang.rs @@ -91,7 +91,7 @@ impl ContinuousCDF for Erlang { /// /// # Formula /// - /// ```ignore + /// ```text /// γ(k, λx) (k - 1)! /// ``` /// @@ -107,7 +107,7 @@ impl ContinuousCDF for Erlang { /// /// # Formula /// - /// ```ignore + /// ```text /// γ(k, λx) (k - 1)! /// ``` /// @@ -125,7 +125,7 @@ impl Min for Erlang { /// /// # Formula /// - /// ```ignore + /// ```text /// 0 /// ``` fn min(&self) -> f64 { @@ -140,7 +140,7 @@ impl Max for Erlang { /// /// # Formula /// - /// ```ignore + /// ```text /// INF /// ``` fn max(&self) -> f64 { @@ -158,7 +158,7 @@ impl Distribution for Erlang { /// /// # Formula /// - /// ```ignore + /// ```text /// k / λ /// ``` /// @@ -170,7 +170,7 @@ impl Distribution for Erlang { /// /// # Formula /// - /// ```ignore + /// ```text /// k / λ^2 /// ``` /// @@ -182,7 +182,7 @@ impl Distribution for Erlang { /// /// # Formula /// - /// ```ignore + /// ```text /// k - ln(λ) + ln(Γ(k)) + (1 - k) * ψ(k) /// ``` /// @@ -195,7 +195,7 @@ impl Distribution for Erlang { /// /// # Formula /// - /// ```ignore + /// ```text /// 2 / sqrt(k) /// ``` /// @@ -215,7 +215,7 @@ impl Mode> for Erlang { /// /// # Formula /// - /// ```ignore + /// ```text /// (k - 1) / λ /// ``` /// @@ -236,7 +236,7 @@ impl Continuous for Erlang { /// /// # Formula /// - /// ```ignore + /// ```text /// (λ^k / Γ(k)) * x^(k - 1) * e^(-λ * x) /// ``` /// @@ -256,7 +256,7 @@ impl Continuous for Erlang { /// /// # Formula /// - /// ```ignore + /// ```text /// ln((λ^k / Γ(k)) * x^(k - 1) * e ^(-λ * x)) /// ``` /// diff --git a/src/distribution/exponential.rs b/src/distribution/exponential.rs index 890592d8..f374b9b2 100644 --- a/src/distribution/exponential.rs +++ b/src/distribution/exponential.rs @@ -79,7 +79,7 @@ impl ContinuousCDF for Exp { /// /// # Formula /// - /// ```ignore + /// ```text /// 1 - e^(-λ * x) /// ``` /// @@ -97,7 +97,7 @@ impl ContinuousCDF for Exp { /// /// # Formula /// - /// ```ignore + /// ```text /// e^(-λ * x) /// ``` /// @@ -117,7 +117,7 @@ impl Min for Exp { /// /// # Formula /// - /// ```ignore + /// ```text /// 0 /// ``` fn min(&self) -> f64 { @@ -131,7 +131,7 @@ impl Max for Exp { /// /// # Formula /// - /// ```ignore + /// ```text /// INF /// ``` fn max(&self) -> f64 { @@ -144,7 +144,7 @@ impl Distribution for Exp { /// /// # Formula /// - /// ```ignore + /// ```text /// 1 / λ /// ``` /// @@ -156,7 +156,7 @@ impl Distribution for Exp { /// /// # Formula /// - /// ```ignore + /// ```text /// 1 / λ^2 /// ``` /// @@ -168,7 +168,7 @@ impl Distribution for Exp { /// /// # Formula /// - /// ```ignore + /// ```text /// 1 - ln(λ) /// ``` /// @@ -180,7 +180,7 @@ impl Distribution for Exp { /// /// # Formula /// - /// ```ignore + /// ```text /// 2 /// ``` fn skewness(&self) -> Option { @@ -193,7 +193,7 @@ impl Median for Exp { /// /// # Formula /// - /// ```ignore + /// ```text /// (1 / λ) * ln2 /// ``` /// @@ -208,7 +208,7 @@ impl Mode> for Exp { /// /// # Formula /// - /// ```ignore + /// ```text /// 0 /// ``` fn mode(&self) -> Option { @@ -222,7 +222,7 @@ impl Continuous for Exp { /// /// # Formula /// - /// ```ignore + /// ```text /// λ * e^(-λ * x) /// ``` /// @@ -240,7 +240,7 @@ impl Continuous for Exp { /// /// # Formula /// - /// ```ignore + /// ```text /// ln(λ * e^(-λ * x)) /// ``` /// diff --git a/src/distribution/fisher_snedecor.rs b/src/distribution/fisher_snedecor.rs index 4b8782be..ee70c30e 100644 --- a/src/distribution/fisher_snedecor.rs +++ b/src/distribution/fisher_snedecor.rs @@ -103,7 +103,7 @@ impl ContinuousCDF for FisherSnedecor { /// /// # Formula /// - /// ```ignore + /// ```text /// I_((d1 * x) / (d1 * x + d2))(d1 / 2, d2 / 2) /// ``` /// @@ -129,7 +129,7 @@ impl ContinuousCDF for FisherSnedecor { /// /// # Formula /// - /// ```ignore + /// ```text /// I_(1 - ((d1 * x) / (d1 * x + d2))(d2 / 2, d1 / 2) /// ``` /// @@ -158,7 +158,7 @@ impl Min for FisherSnedecor { /// /// # Formula /// - /// ```ignore + /// ```text /// 0 /// ``` fn min(&self) -> f64 { @@ -173,7 +173,7 @@ impl Max for FisherSnedecor { /// /// # Formula /// - /// ```ignore + /// ```text /// INF /// ``` fn max(&self) -> f64 { @@ -194,7 +194,7 @@ impl Distribution for FisherSnedecor { /// /// # Formula /// - /// ```ignore + /// ```text /// d2 / (d2 - 2) /// ``` /// @@ -218,7 +218,7 @@ impl Distribution for FisherSnedecor { /// /// # Formula /// - /// ```ignore + /// ```text /// (2 * d2^2 * (d1 + d2 - 2)) / (d1 * (d2 - 2)^2 * (d2 - 4)) /// ``` /// @@ -249,7 +249,7 @@ impl Distribution for FisherSnedecor { /// /// # Formula /// - /// ```ignore + /// ```text /// ((2d1 + d2 - 2) * sqrt(8 * (d2 - 4))) / ((d2 - 6) * sqrt(d1 * (d1 + d2 /// - 2))) /// ``` @@ -282,7 +282,7 @@ impl Mode> for FisherSnedecor { /// /// # Formula /// - /// ```ignore + /// ```text /// ((d1 - 2) / d1) * (d2 / (d2 + 2)) /// ``` /// @@ -311,7 +311,7 @@ impl Continuous for FisherSnedecor { /// /// # Formula /// - /// ```ignore + /// ```text /// sqrt(((d1 * x) ^ d1 * d2 ^ d2) / (d1 * x + d2) ^ (d1 + d2)) / (x * β(d1 /// / 2, d2 / 2)) /// ``` @@ -340,7 +340,7 @@ impl Continuous for FisherSnedecor { /// /// # Formula /// - /// ```ignore + /// ```text /// ln(sqrt(((d1 * x) ^ d1 * d2 ^ d2) / (d1 * x + d2) ^ (d1 + d2)) / (x * /// β(d1 / 2, d2 / 2))) /// ``` diff --git a/src/distribution/gamma.rs b/src/distribution/gamma.rs index 7a36a30f..fd993ba5 100644 --- a/src/distribution/gamma.rs +++ b/src/distribution/gamma.rs @@ -99,7 +99,7 @@ impl ContinuousCDF for Gamma { /// /// # Formula /// - /// ```ignore + /// ```text /// (1 / Γ(α)) * γ(α, β * x) /// ``` /// @@ -124,7 +124,7 @@ impl ContinuousCDF for Gamma { /// /// # Formula /// - /// ```ignore + /// ```text /// (1 / Γ(α)) * γ(α, β * x) /// ``` /// @@ -156,7 +156,7 @@ impl Min for Gamma { /// /// # Formula /// - /// ```ignore + /// ```text /// 0 /// ``` fn min(&self) -> f64 { @@ -171,7 +171,7 @@ impl Max for Gamma { /// /// # Formula /// - /// ```ignore + /// ```text /// INF /// ``` fn max(&self) -> f64 { @@ -184,7 +184,7 @@ impl Distribution for Gamma { /// /// # Formula /// - /// ```ignore + /// ```text /// α / β /// ``` /// @@ -196,7 +196,7 @@ impl Distribution for Gamma { /// /// # Formula /// - /// ```ignore + /// ```text /// α / β^2 /// ``` /// @@ -208,7 +208,7 @@ impl Distribution for Gamma { /// /// # Formula /// - /// ```ignore + /// ```text /// α - ln(β) + ln(Γ(α)) + (1 - α) * ψ(α) /// ``` /// @@ -224,7 +224,7 @@ impl Distribution for Gamma { /// /// # Formula /// - /// ```ignore + /// ```text /// 2 / sqrt(α) /// ``` /// @@ -239,7 +239,7 @@ impl Mode> for Gamma { /// /// # Formula /// - /// ```ignore + /// ```text /// (α - 1) / β /// ``` /// @@ -260,7 +260,7 @@ impl Continuous for Gamma { /// /// # Formula /// - /// ```ignore + /// ```text /// (β^α / Γ(α)) * x^(α - 1) * e^(-β * x) /// ``` /// @@ -291,7 +291,7 @@ impl Continuous for Gamma { /// /// # Formula /// - /// ```ignore + /// ```text /// ln((β^α / Γ(α)) * x^(α - 1) * e ^(-β * x)) /// ``` /// diff --git a/src/distribution/geometric.rs b/src/distribution/geometric.rs index a6e390d7..c7e801c1 100644 --- a/src/distribution/geometric.rs +++ b/src/distribution/geometric.rs @@ -85,7 +85,7 @@ impl DiscreteCDF for Geometric { /// /// # Formula /// - /// ```ignore + /// ```text /// 1 - (1 - p) ^ x /// ``` fn cdf(&self, x: u64) -> f64 { @@ -104,7 +104,7 @@ impl DiscreteCDF for Geometric { /// /// # Formula /// - /// ```ignore + /// ```text /// (1 - p) ^ x /// ``` fn sf(&self, x: u64) -> f64 { @@ -125,7 +125,7 @@ impl Min for Geometric { /// /// # Formula /// - /// ```ignore + /// ```text /// 1 /// ``` fn min(&self) -> u64 { @@ -140,7 +140,7 @@ impl Max for Geometric { /// /// # Formula /// - /// ```ignore + /// ```text /// 2^63 - 1 /// ``` fn max(&self) -> u64 { @@ -153,7 +153,7 @@ impl Distribution for Geometric { /// /// # Formula /// - /// ```ignore + /// ```text /// 1 / p /// ``` fn mean(&self) -> Option { @@ -163,7 +163,7 @@ impl Distribution for Geometric { /// /// # Formula /// - /// ```ignore + /// ```text /// (1 - p) / p^2 /// ``` fn variance(&self) -> Option { @@ -173,7 +173,7 @@ impl Distribution for Geometric { /// /// # Formula /// - /// ```ignore + /// ```text /// (-(1 - p) * log_2(1 - p) - p * log_2(p)) / p /// ``` fn entropy(&self) -> Option { @@ -184,7 +184,7 @@ impl Distribution for Geometric { /// /// # Formula /// - /// ```ignore + /// ```text /// (2 - p) / sqrt(1 - p) /// ``` fn skewness(&self) -> Option { @@ -200,7 +200,7 @@ impl Mode> for Geometric { /// /// # Formula /// - /// ```ignore + /// ```text /// 1 /// ``` fn mode(&self) -> Option { @@ -215,7 +215,7 @@ impl Median for Geometric { /// /// # Formula /// - /// ```ignore + /// ```text /// ceil(-1 / log_2(1 - p)) /// ``` fn median(&self) -> f64 { @@ -229,7 +229,7 @@ impl Discrete for Geometric { /// /// # Formula /// - /// ```ignore + /// ```text /// (1 - p)^(x - 1) * p /// ``` fn pmf(&self, x: u64) -> f64 { @@ -245,7 +245,7 @@ impl Discrete for Geometric { /// /// # Formula /// - /// ```ignore + /// ```text /// ln((1 - p)^(x - 1) * p) /// ``` fn ln_pmf(&self, x: u64) -> f64 { diff --git a/src/distribution/hypergeometric.rs b/src/distribution/hypergeometric.rs index 2aefe1da..95f44d18 100644 --- a/src/distribution/hypergeometric.rs +++ b/src/distribution/hypergeometric.rs @@ -139,7 +139,7 @@ impl DiscreteCDF for Hypergeometric { /// /// # Formula /// - /// ```ignore + /// ```text /// 1 - ((n choose x+1) * (N-n choose K-x-1)) / (N choose K) * 3_F_2(1, /// x+1-K, x+1-n; k+2, N+x+2-K-n; 1) /// ``` @@ -173,7 +173,7 @@ impl DiscreteCDF for Hypergeometric { /// /// # Formula /// - /// ```ignore + /// ```text /// 1 - ((n choose x+1) * (N-n choose K-x-1)) / (N choose K) * 3_F_2(1, /// x+1-K, x+1-n; x+2, N+x+2-K-n; 1) /// ``` @@ -193,7 +193,7 @@ impl DiscreteCDF for Hypergeometric { } else { let k = x; let ln_denom = factorial::ln_binomial(self.population, self.draws); - (k + 1 .. self.max() + 1).fold(0.0, |acc, i| { + (k + 1..self.max() + 1).fold(0.0, |acc, i| { acc + (factorial::ln_binomial(self.successes, i) + factorial::ln_binomial(self.population - self.successes, self.draws - i) - ln_denom) @@ -210,7 +210,7 @@ impl Min for Hypergeometric { /// /// # Formula /// - /// ```ignore + /// ```text /// max(0, n + K - N) /// ``` /// @@ -227,7 +227,7 @@ impl Max for Hypergeometric { /// /// # Formula /// - /// ```ignore + /// ```text /// min(K, n) /// ``` /// @@ -246,7 +246,7 @@ impl Distribution for Hypergeometric { /// /// # Formula /// - /// ```ignore + /// ```text /// K * n / N /// ``` /// @@ -266,7 +266,7 @@ impl Distribution for Hypergeometric { /// /// # Formula /// - /// ```ignore + /// ```text /// n * (K / N) * ((N - K) / N) * ((N - n) / (N - 1)) /// ``` /// @@ -289,7 +289,7 @@ impl Distribution for Hypergeometric { /// /// # Formula /// - /// ```ignore + /// ```text /// ((N - 2K) * (N - 1)^(1 / 2) * (N - 2n)) / ([n * K * (N - K) * (N - /// n)]^(1 / 2) * (N - 2)) /// ``` @@ -315,7 +315,7 @@ impl Mode> for Hypergeometric { /// /// # Formula /// - /// ```ignore + /// ```text /// floor((n + 1) * (k + 1) / (N + 2)) /// ``` /// @@ -331,7 +331,7 @@ impl Discrete for Hypergeometric { /// /// # Formula /// - /// ```ignore + /// ```text /// (K choose x) * (N-K choose n-x) / (N choose n) /// ``` /// @@ -351,7 +351,7 @@ impl Discrete for Hypergeometric { /// /// # Formula /// - /// ```ignore + /// ```text /// ln((K choose x) * (N-K choose n-x) / (N choose n)) /// ``` /// diff --git a/src/distribution/inverse_gamma.rs b/src/distribution/inverse_gamma.rs index 1cf69fa9..e439be45 100644 --- a/src/distribution/inverse_gamma.rs +++ b/src/distribution/inverse_gamma.rs @@ -99,7 +99,7 @@ impl ContinuousCDF for InverseGamma { /// /// # Formula /// - /// ```ignore + /// ```text /// Γ(α, β / x) / Γ(α) /// ``` /// @@ -121,7 +121,7 @@ impl ContinuousCDF for InverseGamma { /// /// # Formula /// - /// ```ignore + /// ```text /// Γ(α, β / x) / Γ(α) /// ``` /// @@ -146,7 +146,7 @@ impl Min for InverseGamma { /// /// # Formula /// - /// ```ignore + /// ```text /// 0 /// ``` fn min(&self) -> f64 { @@ -161,7 +161,7 @@ impl Max for InverseGamma { /// /// # Formula /// - /// ```ignore + /// ```text /// INF /// ``` fn max(&self) -> f64 { @@ -178,7 +178,7 @@ impl Distribution for InverseGamma { /// /// # Formula /// - /// ```ignore + /// ```text /// β / (α - 1) /// ``` /// @@ -198,7 +198,7 @@ impl Distribution for InverseGamma { /// /// # Formula /// - /// ```ignore + /// ```text /// β^2 / ((α - 1)^2 * (α - 2)) /// ``` /// @@ -216,7 +216,7 @@ impl Distribution for InverseGamma { /// /// # Formula /// - /// ```ignore + /// ```text /// α + ln(β * Γ(α)) - (1 + α) * ψ(α) /// ``` /// @@ -235,7 +235,7 @@ impl Distribution for InverseGamma { /// /// # Formula /// - /// ```ignore + /// ```text /// 4 * sqrt(α - 2) / (α - 3) /// ``` /// @@ -254,7 +254,7 @@ impl Mode> for InverseGamma { /// /// # Formula /// - /// ```ignore + /// ```text /// β / (α + 1) /// ``` /// @@ -270,7 +270,7 @@ impl Continuous for InverseGamma { /// /// # Formula /// - /// ```ignore + /// ```text /// (β^α / Γ(α)) * x^(-α - 1) * e^(-β / x) /// ``` /// @@ -291,7 +291,7 @@ impl Continuous for InverseGamma { /// /// # Formula /// - /// ```ignore + /// ```text /// ln((β^α / Γ(α)) * x^(-α - 1) * e^(-β / x)) /// ``` /// diff --git a/src/distribution/laplace.rs b/src/distribution/laplace.rs index 2d3d5590..4f73b278 100644 --- a/src/distribution/laplace.rs +++ b/src/distribution/laplace.rs @@ -92,7 +92,7 @@ impl ContinuousCDF for Laplace { /// /// # Formula /// - /// ```ignore + /// ```text /// (1 / 2) * (1 + signum(x - μ)) - signum(x - μ) * exp(-|x - μ| / b) /// ``` /// @@ -111,7 +111,7 @@ impl ContinuousCDF for Laplace { /// /// # Formula /// - /// ```ignore + /// ```text /// 1 - [(1 / 2) * (1 + signum(x - μ)) - signum(x - μ) * exp(-|x - μ| / b)] /// ``` /// @@ -131,11 +131,11 @@ impl ContinuousCDF for Laplace { /// # Formula /// /// if p <= 1/2 - /// ```ignore + /// ```text /// μ + b * ln(2p) /// ``` /// if p >= 1/2 - /// ```ignore + /// ```text /// μ - b * ln(2 - 2p) /// ``` /// @@ -158,7 +158,7 @@ impl Min for Laplace { /// /// # Formula /// - /// ```ignore + /// ```text /// NEG_INF /// ``` fn min(&self) -> f64 { @@ -172,7 +172,7 @@ impl Max for Laplace { /// /// # Formula /// - /// ```ignore + /// ```text /// INF /// ``` fn max(&self) -> f64 { @@ -185,7 +185,7 @@ impl Distribution for Laplace { /// /// # Formula /// - /// ```ignore + /// ```text /// μ /// ``` /// @@ -197,7 +197,7 @@ impl Distribution for Laplace { /// /// # Formula /// - /// ```ignore + /// ```text /// 2*b^2 /// ``` /// @@ -209,7 +209,7 @@ impl Distribution for Laplace { /// /// # Formula /// - /// ```ignore + /// ```text /// ln(2be) /// ``` /// @@ -221,7 +221,7 @@ impl Distribution for Laplace { /// /// # Formula /// - /// ```ignore + /// ```text /// 0 /// ``` fn skewness(&self) -> Option { @@ -234,7 +234,7 @@ impl Median for Laplace { /// /// # Formula /// - /// ```ignore + /// ```text /// μ /// ``` /// @@ -249,7 +249,7 @@ impl Mode> for Laplace { /// /// # Formula /// - /// ```ignore + /// ```text /// μ /// ``` /// @@ -265,7 +265,7 @@ impl Continuous for Laplace { /// /// # Formula /// - /// ```ignore + /// ```text /// (1 / 2b) * exp(-|x - μ| / b) /// ``` /// where `μ` is the location and `b` is the scale @@ -278,7 +278,7 @@ impl Continuous for Laplace { /// /// # Formula /// - /// ```ignore + /// ```text /// ln((1 / 2b) * exp(-|x - μ| / b)) /// ``` /// diff --git a/src/distribution/log_normal.rs b/src/distribution/log_normal.rs index 13854f6f..6698dd2a 100644 --- a/src/distribution/log_normal.rs +++ b/src/distribution/log_normal.rs @@ -68,7 +68,7 @@ impl ContinuousCDF for LogNormal { /// /// # Formula /// - /// ```ignore + /// ```text /// (1 / 2) + (1 / 2) * erf((ln(x) - μ) / sqrt(2) * σ) /// ``` /// @@ -89,7 +89,7 @@ impl ContinuousCDF for LogNormal { /// /// # Formula /// - /// ```ignore + /// ```text /// (1 / 2) + (1 / 2) * erf(-(ln(x) - μ) / sqrt(2) * σ) /// ``` /// @@ -100,9 +100,9 @@ impl ContinuousCDF for LogNormal { /// the sign of the argument error function with respect to the cdf. /// /// the normal cdf Φ (and internal error function) as the following property: - /// ```ignore + /// ```text /// Φ(-x) + Φ(x) = 1 - /// Φ(-x) = 1 - Φ(x) + /// Φ(-x) = 1 - Φ(x) /// ``` fn sf(&self, x: f64) -> f64 { if x <= 0.0 { @@ -121,7 +121,7 @@ impl Min for LogNormal { /// /// # Formula /// - /// ```ignore + /// ```text /// 0 /// ``` fn min(&self) -> f64 { @@ -135,7 +135,7 @@ impl Max for LogNormal { /// /// # Formula /// - /// ```ignore + /// ```text /// INF /// ``` fn max(&self) -> f64 { @@ -148,7 +148,7 @@ impl Distribution for LogNormal { /// /// # Formula /// - /// ```ignore + /// ```text /// e^(μ + σ^2 / 2) /// ``` /// @@ -160,7 +160,7 @@ impl Distribution for LogNormal { /// /// # Formula /// - /// ```ignore + /// ```text /// (e^(σ^2) - 1) * e^(2μ + σ^2) /// ``` /// @@ -173,7 +173,7 @@ impl Distribution for LogNormal { /// /// # Formula /// - /// ```ignore + /// ```text /// ln(σe^(μ + 1 / 2) * sqrt(2π)) /// ``` /// @@ -185,7 +185,7 @@ impl Distribution for LogNormal { /// /// # Formula /// - /// ```ignore + /// ```text /// (e^(σ^2) + 2) * sqrt(e^(σ^2) - 1) /// ``` /// @@ -201,7 +201,7 @@ impl Median for LogNormal { /// /// # Formula /// - /// ```ignore + /// ```text /// e^μ /// ``` /// @@ -216,7 +216,7 @@ impl Mode> for LogNormal { /// /// # Formula /// - /// ```ignore + /// ```text /// e^(μ - σ^2) /// ``` /// @@ -232,7 +232,7 @@ impl Continuous for LogNormal { /// /// # Formula /// - /// ```ignore + /// ```text /// (1 / xσ * sqrt(2π)) * e^(-((ln(x) - μ)^2) / 2σ^2) /// ``` /// @@ -251,7 +251,7 @@ impl Continuous for LogNormal { /// /// # Formula /// - /// ```ignore + /// ```text /// ln((1 / xσ * sqrt(2π)) * e^(-((ln(x) - μ)^2) / 2σ^2)) /// ``` /// diff --git a/src/distribution/multinomial.rs b/src/distribution/multinomial.rs index a4f0524d..31de9e57 100644 --- a/src/distribution/multinomial.rs +++ b/src/distribution/multinomial.rs @@ -108,7 +108,7 @@ impl MeanN> for Multinomial { /// /// # Formula /// - /// ```ignore + /// ```text /// n * p_i for i in 1...k /// ``` /// @@ -126,7 +126,7 @@ impl VarianceN> for Multinomial { /// /// # Formula /// - /// ```ignore + /// ```text /// n * p_i * (1 - p_i) for i in 1...k /// ``` /// @@ -147,7 +147,7 @@ impl VarianceN> for Multinomial { // /// // /// # Formula // /// -// /// ```ignore +// /// ```text // /// (1 - 2 * p_i) / (n * p_i * (1 - p_i)) for i in 1...k // /// ``` // /// @@ -176,7 +176,7 @@ impl<'a> Discrete<&'a [u64], f64> for Multinomial { /// /// # Formula /// - /// ```ignore + /// ```text /// (n! / x_1!...x_k!) * p_i^x_i for i in 1...k /// ``` /// @@ -212,7 +212,7 @@ impl<'a> Discrete<&'a [u64], f64> for Multinomial { /// /// # Formula /// - /// ```ignore + /// ```text /// ln((n! / x_1!...x_k!) * p_i^x_i) for i in 1...k /// ``` /// diff --git a/src/distribution/multivariate_normal.rs b/src/distribution/multivariate_normal.rs index 75902a4b..b41a09e1 100644 --- a/src/distribution/multivariate_normal.rs +++ b/src/distribution/multivariate_normal.rs @@ -83,7 +83,7 @@ impl MultivariateNormal { /// /// # Formula /// - /// ```ignore + /// ```text /// (1 / 2) * ln(det(2 * π * e * Σ)) /// ``` /// @@ -104,7 +104,9 @@ impl ::rand::distributions::Distribution> for MultivariateNormal { /// Samples from the multivariate normal distribution /// /// # Formula + /// ```text /// L * Z + μ + /// ``` /// /// where `L` is the Cholesky decomposition of the covariance matrix, /// `Z` is a vector of normally distributed random variables, and @@ -160,7 +162,7 @@ impl Mode> for MultivariateNormal { /// /// # Formula /// - /// ```ignore + /// ```text /// μ /// ``` /// @@ -176,7 +178,7 @@ impl<'a> Continuous<&'a DVector, f64> for MultivariateNormal { /// /// # Formula /// - /// ```ignore + /// ```text /// (2 * π) ^ (-k / 2) * det(Σ) ^ (1 / 2) * e ^ ( -(1 / 2) * transpose(x - μ) * inv(Σ) * (x - μ)) /// ``` /// @@ -208,7 +210,7 @@ impl Continuous, f64> for MultivariateNormal { /// /// # Formula /// - /// ```ignore + /// ```text /// (2 * π) ^ (-k / 2) * det(Σ) ^ (1 / 2) * e ^ ( -(1 / 2) * transpose(x - μ) * inv(Σ) * (x - μ)) /// ``` /// diff --git a/src/distribution/negative_binomial.rs b/src/distribution/negative_binomial.rs index a9ed077a..4c23079c 100644 --- a/src/distribution/negative_binomial.rs +++ b/src/distribution/negative_binomial.rs @@ -117,7 +117,7 @@ impl DiscreteCDF for NegativeBinomial { /// /// # Formula /// - /// ```ignore + /// ```text /// I_(p)(r, x+1) /// ``` /// @@ -137,7 +137,7 @@ impl DiscreteCDF for NegativeBinomial { /// /// # Formula /// - /// ```ignore + /// ```text /// I_(1-p)(x+1, r) /// ``` /// @@ -154,7 +154,7 @@ impl Min for NegativeBinomial { /// /// # Formula /// - /// ```ignore + /// ```text /// 0 /// ``` fn min(&self) -> u64 { @@ -169,7 +169,7 @@ impl Max for NegativeBinomial { /// /// # Formula /// - /// ```ignore + /// ```text /// u64::MAX /// ``` fn max(&self) -> u64 { @@ -182,7 +182,7 @@ impl DiscreteDistribution for NegativeBinomial { /// /// # Formula /// - /// ```ignore + /// ```text /// r * (1-p) / p /// ``` fn mean(&self) -> Option { @@ -192,7 +192,7 @@ impl DiscreteDistribution for NegativeBinomial { /// /// # Formula /// - /// ```ignore + /// ```text /// r * (1-p) / p^2 /// ``` fn variance(&self) -> Option { @@ -202,7 +202,7 @@ impl DiscreteDistribution for NegativeBinomial { /// /// # Formula /// - /// ```ignore + /// ```text /// (2-p) / sqrt(r * (1-p)) /// ``` fn skewness(&self) -> Option { @@ -215,7 +215,7 @@ impl Mode> for NegativeBinomial { /// /// # Formula /// - /// ```ignore + /// ```text /// if r > 1 then /// floor((r - 1) * (1-p / p)) /// else @@ -239,13 +239,13 @@ impl Discrete for NegativeBinomial { /// /// When `r` is an integer, the formula is: /// - /// ```ignore + /// ```text /// (x + r - 1 choose x) * (1 - p)^x * p^r /// ``` /// /// The general formula for real `r` is: /// - /// ```ignore + /// ```text /// Γ(r + x)/(Γ(r) * Γ(x + 1)) * (1 - p)^x * p^r /// ``` /// @@ -261,13 +261,13 @@ impl Discrete for NegativeBinomial { /// /// When `r` is an integer, the formula is: /// - /// ```ignore + /// ```text /// ln((x + r - 1 choose x) * (1 - p)^x * p^r) /// ``` /// /// The general formula for real `r` is: /// - /// ```ignore + /// ```text /// ln(Γ(r + x)/(Γ(r) * Γ(x + 1)) * (1 - p)^x * p^r) /// ``` /// diff --git a/src/distribution/normal.rs b/src/distribution/normal.rs index dabb7915..d1cc91f2 100644 --- a/src/distribution/normal.rs +++ b/src/distribution/normal.rs @@ -65,7 +65,7 @@ impl ContinuousCDF for Normal { /// /// # Formula /// - /// ```ignore + /// ```text /// (1 / 2) * (1 + erf((x - μ) / (σ * sqrt(2)))) /// ``` /// @@ -80,7 +80,7 @@ impl ContinuousCDF for Normal { /// /// # Formula /// - /// ```ignore + /// ```text /// (1 / 2) * (1 + erf(-(x - μ) / (σ * sqrt(2)))) /// ``` /// @@ -91,9 +91,9 @@ impl ContinuousCDF for Normal { /// the sign of the argument error function with respect to the cdf. /// /// the normal cdf Φ (and internal error function) as the following property: - /// ```ignore + /// ```text /// Φ(-x) + Φ(x) = 1 - /// Φ(-x) = 1 - Φ(x) + /// Φ(-x) = 1 - Φ(x) /// ``` fn sf(&self, x: f64) -> f64 { sf_unchecked(x, self.mean, self.std_dev) @@ -108,7 +108,7 @@ impl ContinuousCDF for Normal { /// /// # Formula /// - /// ```ignore + /// ```text /// μ - sqrt(2) * σ * erfc_inv(2x) /// ``` /// @@ -129,7 +129,7 @@ impl Min for Normal { /// /// # Formula /// - /// ```ignore + /// ```text /// -INF /// ``` fn min(&self) -> f64 { @@ -143,7 +143,7 @@ impl Max for Normal { /// /// # Formula /// - /// ```ignore + /// ```text /// INF /// ``` fn max(&self) -> f64 { @@ -164,7 +164,7 @@ impl Distribution for Normal { /// /// # Formula /// - /// ```ignore + /// ```text /// σ^2 /// ``` /// @@ -176,7 +176,7 @@ impl Distribution for Normal { /// /// # Formula /// - /// ```ignore + /// ```text /// (1 / 2) * ln(2σ^2 * π * e) /// ``` /// @@ -188,7 +188,7 @@ impl Distribution for Normal { /// /// # Formula /// - /// ```ignore + /// ```text /// 0 /// ``` fn skewness(&self) -> Option { @@ -201,7 +201,7 @@ impl Median for Normal { /// /// # Formula /// - /// ```ignore + /// ```text /// μ /// ``` /// @@ -216,7 +216,7 @@ impl Mode> for Normal { /// /// # Formula /// - /// ```ignore + /// ```text /// μ /// ``` /// @@ -232,7 +232,7 @@ impl Continuous for Normal { /// /// # Formula /// - /// ```ignore + /// ```text /// (1 / sqrt(2σ^2 * π)) * e^(-(x - μ)^2 / 2σ^2) /// ``` /// @@ -247,7 +247,7 @@ impl Continuous for Normal { /// /// # Formula /// - /// ```ignore + /// ```text /// ln((1 / sqrt(2σ^2 * π)) * e^(-(x - μ)^2 / 2σ^2)) /// ``` /// diff --git a/src/distribution/pareto.rs b/src/distribution/pareto.rs index e59595a2..eca17f82 100644 --- a/src/distribution/pareto.rs +++ b/src/distribution/pareto.rs @@ -97,7 +97,7 @@ impl ContinuousCDF for Pareto { /// /// # Formula /// - /// ```ignore + /// ```text /// if x < x_m { /// 0 /// } else { @@ -119,7 +119,7 @@ impl ContinuousCDF for Pareto { /// /// # Formula /// - /// ```ignore + /// ```text /// if x < x_m { /// 1 /// } else { @@ -143,7 +143,7 @@ impl Min for Pareto { /// /// # Formula /// - /// ```ignore + /// ```text /// x_m /// ``` /// @@ -159,7 +159,7 @@ impl Max for Pareto { /// /// # Formula /// - /// ```ignore + /// ```text /// INF /// ``` fn max(&self) -> f64 { @@ -172,7 +172,7 @@ impl Distribution for Pareto { /// /// # Formula /// - /// ```ignore + /// ```text /// if α <= 1 { /// INF /// } else { @@ -192,7 +192,7 @@ impl Distribution for Pareto { /// /// # Formula /// - /// ```ignore + /// ```text /// if α <= 2 { /// INF /// } else { @@ -213,7 +213,7 @@ impl Distribution for Pareto { /// /// # Formula /// - /// ```ignore + /// ```text /// ln(α/x_m) - 1/α - 1 /// ``` /// @@ -231,7 +231,7 @@ impl Distribution for Pareto { /// /// # Formula /// - /// ```ignore + /// ```text /// (2*(α + 1)/(α - 3))*sqrt((α - 2)/α) /// ``` /// @@ -253,7 +253,7 @@ impl Median for Pareto { /// /// # Formula /// - /// ```ignore + /// ```text /// x_m*2^(1/α) /// ``` /// @@ -268,7 +268,7 @@ impl Mode> for Pareto { /// /// # Formula /// - /// ```ignore + /// ```text /// x_m /// ``` /// @@ -284,7 +284,7 @@ impl Continuous for Pareto { /// /// # Formula /// - /// ```ignore + /// ```text /// if x < x_m { /// 0 /// } else { @@ -306,7 +306,7 @@ impl Continuous for Pareto { /// /// # Formula /// - /// ```ignore + /// ```text /// if x < x_m { /// -INF /// } else { diff --git a/src/distribution/poisson.rs b/src/distribution/poisson.rs index 9879b6a8..47d614ce 100644 --- a/src/distribution/poisson.rs +++ b/src/distribution/poisson.rs @@ -84,7 +84,7 @@ impl DiscreteCDF for Poisson { /// /// # Formula /// - /// ```ignore + /// ```text /// P(x + 1, λ) /// ``` /// @@ -98,7 +98,7 @@ impl DiscreteCDF for Poisson { /// /// # Formula /// - /// ```ignore + /// ```text /// P(x + 1, λ) /// ``` /// @@ -114,7 +114,7 @@ impl Min for Poisson { /// /// # Formula /// - /// ```ignore + /// ```text /// 0 /// ``` fn min(&self) -> u64 { @@ -128,7 +128,7 @@ impl Max for Poisson { /// /// # Formula /// - /// ```ignore + /// ```text /// 2^63 - 1 /// ``` fn max(&self) -> u64 { @@ -141,7 +141,7 @@ impl Distribution for Poisson { /// /// # Formula /// - /// ```ignore + /// ```text /// λ /// ``` /// @@ -153,7 +153,7 @@ impl Distribution for Poisson { /// /// # Formula /// - /// ```ignore + /// ```text /// λ /// ``` /// @@ -165,7 +165,7 @@ impl Distribution for Poisson { /// /// # Formula /// - /// ```ignore + /// ```text /// (1 / 2) * ln(2πeλ) - 1 / (12λ) - 1 / (24λ^2) - 19 / (360λ^3) /// ``` /// @@ -182,7 +182,7 @@ impl Distribution for Poisson { /// /// # Formula /// - /// ```ignore + /// ```text /// λ^(-1/2) /// ``` /// @@ -197,7 +197,7 @@ impl Median for Poisson { /// /// # Formula /// - /// ```ignore + /// ```text /// floor(λ + 1 / 3 - 0.02 / λ) /// ``` /// @@ -212,7 +212,7 @@ impl Mode> for Poisson { /// /// # Formula /// - /// ```ignore + /// ```text /// floor(λ) /// ``` /// @@ -228,7 +228,7 @@ impl Discrete for Poisson { /// /// # Formula /// - /// ```ignore + /// ```text /// (λ^x * e^(-λ)) / x! /// ``` /// @@ -243,7 +243,7 @@ impl Discrete for Poisson { /// /// # Formula /// - /// ```ignore + /// ```text /// ln((λ^x * e^(-λ)) / x!) /// ``` /// diff --git a/src/distribution/students_t.rs b/src/distribution/students_t.rs index 277647bf..21981513 100644 --- a/src/distribution/students_t.rs +++ b/src/distribution/students_t.rs @@ -124,7 +124,7 @@ impl ContinuousCDF for StudentsT { /// /// # Formula /// - /// ```ignore + /// ```text /// if x < μ { /// (1 / 2) * I(t, v / 2, 1 / 2) /// } else { @@ -156,7 +156,7 @@ impl ContinuousCDF for StudentsT { /// /// # Formula /// - /// ```ignore + /// ```text /// if x < μ { /// 1 - (1 / 2) * I(t, v / 2, 1 / 2) /// } else { @@ -209,7 +209,7 @@ impl Min for StudentsT { /// /// # Formula /// - /// ```ignore + /// ```text /// -INF /// ``` fn min(&self) -> f64 { @@ -223,7 +223,7 @@ impl Max for StudentsT { /// /// # Formula /// - /// ```ignore + /// ```text /// INF /// ``` fn max(&self) -> f64 { @@ -240,7 +240,7 @@ impl Distribution for StudentsT { /// /// # Formula /// - /// ```ignore + /// ```text /// μ /// ``` /// @@ -260,7 +260,7 @@ impl Distribution for StudentsT { /// /// # Formula /// - /// ```ignore + /// ```text /// if v == INF { /// Some(σ^2) /// } else if freedom > 2.0 { @@ -284,7 +284,7 @@ impl Distribution for StudentsT { /// /// # Formula /// - /// ```ignore + /// ```text /// - ln(σ) + (v + 1) / 2 * (ψ((v + 1) / 2) - ψ(v / 2)) + ln(sqrt(v) * B(v / 2, 1 / /// 2)) /// ``` @@ -309,7 +309,7 @@ impl Distribution for StudentsT { /// /// # Formula /// - /// ```ignore + /// ```text /// 0 /// ``` fn skewness(&self) -> Option { @@ -326,7 +326,7 @@ impl Median for StudentsT { /// /// # Formula /// - /// ```ignore + /// ```text /// μ /// ``` /// @@ -341,7 +341,7 @@ impl Mode> for StudentsT { /// /// # Formula /// - /// ```ignore + /// ```text /// μ /// ``` /// @@ -358,7 +358,7 @@ impl Continuous for StudentsT { /// /// # Formula /// - /// ```ignore + /// ```text /// Γ((v + 1) / 2) / (sqrt(vπ) * Γ(v / 2) * σ) * (1 + k^2 / v)^(-1 / 2 * (v /// + 1)) /// ``` @@ -387,7 +387,7 @@ impl Continuous for StudentsT { /// /// # Formula /// - /// ```ignore + /// ```text /// ln(Γ((v + 1) / 2) / (sqrt(vπ) * Γ(v / 2) * σ) * (1 + k^2 / v)^(-1 / 2 * /// (v + 1))) /// ``` diff --git a/src/distribution/triangular.rs b/src/distribution/triangular.rs index 068f6c9a..a9cb98a9 100644 --- a/src/distribution/triangular.rs +++ b/src/distribution/triangular.rs @@ -72,7 +72,7 @@ impl ContinuousCDF for Triangular { /// /// # Formula /// - /// ```ignore + /// ```text /// if x == min { /// 0 /// } if min < x <= mode { @@ -103,7 +103,7 @@ impl ContinuousCDF for Triangular { /// /// # Formula /// - /// ```ignore + /// ```text /// if x == min { /// 1 /// } if min < x <= mode { @@ -159,7 +159,7 @@ impl Distribution for Triangular { /// /// # Formula /// - /// ```ignore + /// ```text /// (min + max + mode) / 3 /// ``` fn mean(&self) -> Option { @@ -169,7 +169,7 @@ impl Distribution for Triangular { /// /// # Formula /// - /// ```ignore + /// ```text /// (min^2 + max^2 + mode^2 - min * max - min * mode - max * mode) / 18 /// ``` fn variance(&self) -> Option { @@ -182,7 +182,7 @@ impl Distribution for Triangular { /// /// # Formula /// - /// ```ignore + /// ```text /// 1 / 2 + ln((max - min) / 2) /// ``` fn entropy(&self) -> Option { @@ -192,7 +192,7 @@ impl Distribution for Triangular { /// /// # Formula /// - /// ```ignore + /// ```text /// (sqrt(2) * (min + max - 2 * mode) * (2 * min - max - mode) * (min - 2 * /// max + mode)) / /// ( 5 * (min^2 + max^2 + mode^2 - min * max - min * mode - max * mode)^(3 @@ -213,7 +213,7 @@ impl Median for Triangular { /// /// # Formula /// - /// ```ignore + /// ```text /// if mode >= (min + max) / 2 { /// min + sqrt((max - min) * (mode - min) / 2) /// } else { @@ -237,7 +237,7 @@ impl Mode> for Triangular { /// /// # Formula /// - /// ```ignore + /// ```text /// mode /// ``` fn mode(&self) -> Option { @@ -252,7 +252,7 @@ impl Continuous for Triangular { /// /// # Formula /// - /// ```ignore + /// ```text /// if x < min { /// 0 /// } else if min <= x <= mode { @@ -282,7 +282,7 @@ impl Continuous for Triangular { /// /// # Formula /// - /// ```ignore + /// ```text /// ln( if x < min { /// 0 /// } else if min <= x <= mode { diff --git a/src/distribution/uniform.rs b/src/distribution/uniform.rs index bca6590b..c5f7d776 100644 --- a/src/distribution/uniform.rs +++ b/src/distribution/uniform.rs @@ -68,7 +68,7 @@ impl ContinuousCDF for Uniform { /// /// # Formula /// - /// ```ignore + /// ```text /// (x - min) / (max - min) /// ``` fn cdf(&self, x: f64) -> f64 { @@ -86,7 +86,7 @@ impl ContinuousCDF for Uniform { /// /// # Formula /// - /// ```ignore + /// ```text /// (max - x) / (max - min) /// ``` fn sf(&self, x: f64) -> f64 { @@ -121,7 +121,7 @@ impl Distribution for Uniform { /// /// # Formula /// - /// ```ignore + /// ```text /// (min + max) / 2 /// ``` fn mean(&self) -> Option { @@ -131,7 +131,7 @@ impl Distribution for Uniform { /// /// # Formula /// - /// ```ignore + /// ```text /// (max - min)^2 / 12 /// ``` fn variance(&self) -> Option { @@ -141,7 +141,7 @@ impl Distribution for Uniform { /// /// # Formula /// - /// ```ignore + /// ```text /// ln(max - min) /// ``` fn entropy(&self) -> Option { @@ -151,7 +151,7 @@ impl Distribution for Uniform { /// /// # Formula /// - /// ```ignore + /// ```text /// 0 /// ``` fn skewness(&self) -> Option { @@ -164,7 +164,7 @@ impl Median for Uniform { /// /// # Formula /// - /// ```ignore + /// ```text /// (min + max) / 2 /// ``` fn median(&self) -> f64 { @@ -182,7 +182,7 @@ impl Mode> for Uniform { /// /// # Formula /// - /// ```ignore + /// ```text /// N/A // (max + min) / 2 for the middle element /// ``` fn mode(&self) -> Option { @@ -200,7 +200,7 @@ impl Continuous for Uniform { /// /// # Formula /// - /// ```ignore + /// ```text /// 1 / (max - min) /// ``` fn pdf(&self, x: f64) -> f64 { @@ -221,7 +221,7 @@ impl Continuous for Uniform { /// /// # Formula /// - /// ```ignore + /// ```text /// ln(1 / (max - min)) /// ``` fn ln_pdf(&self, x: f64) -> f64 { diff --git a/src/distribution/weibull.rs b/src/distribution/weibull.rs index eab7d942..c414c20c 100644 --- a/src/distribution/weibull.rs +++ b/src/distribution/weibull.rs @@ -103,7 +103,7 @@ impl ContinuousCDF for Weibull { /// /// # Formula /// - /// ```ignore + /// ```text /// 1 - e^-((x/λ)^k) /// ``` /// @@ -121,7 +121,7 @@ impl ContinuousCDF for Weibull { /// /// # Formula /// - /// ```ignore + /// ```text /// e^-((x/λ)^k) /// ``` /// @@ -141,7 +141,7 @@ impl Min for Weibull { /// /// # Formula /// - /// ```ignore + /// ```text /// 0 /// ``` fn min(&self) -> f64 { @@ -155,7 +155,7 @@ impl Max for Weibull { /// /// # Formula /// - /// ```ignore + /// ```text /// INF /// ``` fn max(&self) -> f64 { @@ -168,7 +168,7 @@ impl Distribution for Weibull { /// /// # Formula /// - /// ```ignore + /// ```text /// λΓ(1 + 1 / k) /// ``` /// @@ -181,7 +181,7 @@ impl Distribution for Weibull { /// /// # Formula /// - /// ```ignore + /// ```text /// λ^2 * (Γ(1 + 2 / k) - Γ(1 + 1 / k)^2) /// ``` /// @@ -195,7 +195,7 @@ impl Distribution for Weibull { /// /// # Formula /// - /// ```ignore + /// ```text /// γ(1 - 1 / k) + ln(λ / k) + 1 /// ``` /// @@ -211,7 +211,7 @@ impl Distribution for Weibull { /// /// # Formula /// - /// ```ignore + /// ```text /// (Γ(1 + 3 / k) * λ^3 - 3μσ^2 - μ^3) / σ^3 /// ``` /// @@ -236,7 +236,7 @@ impl Median for Weibull { /// /// # Formula /// - /// ```ignore + /// ```text /// λ(ln(2))^(1 / k) /// ``` /// @@ -251,7 +251,7 @@ impl Mode> for Weibull { /// /// # Formula /// - /// ```ignore + /// ```text /// if k == 1 { /// 0 /// } else { @@ -276,7 +276,7 @@ impl Continuous for Weibull { /// /// # Formula /// - /// ```ignore + /// ```text /// (k / λ) * (x / λ)^(k - 1) * e^(-(x / λ)^k) /// ``` /// @@ -301,7 +301,7 @@ impl Continuous for Weibull { /// /// # Formula /// - /// ```ignore + /// ```text /// ln((k / λ) * (x / λ)^(k - 1) * e^(-(x / λ)^k)) /// ``` /// From d78feaf60a46f612854615b8bdf56ff84c3a51f7 Mon Sep 17 00:00:00 2001 From: Orion Yeung <11580988+orionyeung001@users.noreply.github.com> Date: Mon, 18 Mar 2024 19:32:42 -0500 Subject: [PATCH 3/7] doc: alias `inverse_cdf` as "quantile function" in docs --- src/distribution/mod.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/distribution/mod.rs b/src/distribution/mod.rs index a9718ee6..562eb2bc 100644 --- a/src/distribution/mod.rs +++ b/src/distribution/mod.rs @@ -111,6 +111,8 @@ pub trait ContinuousCDF: Min + Max { /// Performs a binary search on the domain of `cdf` to obtain an approximation /// of `F^-1(p) := inf { x | F(x) >= p }`. Needless to say, performance may /// may be lacking. + #[doc(alias = "quantile function")] + #[doc(alias = "quantile")] fn inverse_cdf(&self, p: T) -> K { if p == T::zero() { return self.min(); From d60a12c4b755425c52e12629dc1ee0734ab438c8 Mon Sep 17 00:00:00 2001 From: Orion Yeung <11580988+orionyeung001@users.noreply.github.com> Date: Thu, 14 Mar 2024 10:52:23 -0500 Subject: [PATCH 4/7] chore: update rustfmt to make changes --- rustfmt.toml | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/rustfmt.toml b/rustfmt.toml index b42e764f..d1c82741 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,4 +1,33 @@ -# Run using `rustfmt --write-mode overwrite *.rs` in the -# root of the src directory. You may still get some -# formatting errors (whitespace etc) which should be -# fixed manually before committing. +# This rustfmt file is added for configuration, but in practice much of our +# code is hand-formatted, frequently with more readable results. +# taken from rust-random/rand + +# Comments: +normalize_comments = true +wrap_comments = false +comment_width = 90 # small excess is okay but prefer 80 + +# Arguments: +use_small_heuristics = "Default" +# TODO: single line functions only where short, please? +# https://github.com/rust-lang/rustfmt/issues/3358 +fn_single_line = false +fn_params_layout = "Compressed" +overflow_delimited_expr = true +where_single_line = true + +# enum_discrim_align_threshold = 20 +# struct_field_align_threshold = 20 + +# Compatibility: +edition = "2021" + +# Misc: +inline_attribute_width = 80 +blank_lines_upper_bound = 2 +reorder_impl_items = true +# report_todo = "Unnumbered" +# report_fixme = "Unnumbered" + +# Ignored files: +ignore = [] From d589c1bf31e1f0468b1dc607bc8a41988c977b75 Mon Sep 17 00:00:00 2001 From: Orion Yeung <11580988+orionyeung001@users.noreply.github.com> Date: Wed, 3 Apr 2024 10:32:52 -0500 Subject: [PATCH 5/7] chore: format and add contributing content to README format markdown sentences to entire lines. add test status badge add usage of `cargo fmt` to contributing section --- README.md | 49 ++++++++++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 4521bb9b..c6e59dbb 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # statrs -[![Build Status](https://travis-ci.org/boxtown/statrs.svg?branch=master)](https://travis-ci.org/boxtown/statrs) +![tests](https://github.com/statrs-dev/statrs/actions/workflows/test.yml/badge.svg) [![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE.md) [![Crates.io](https://img.shields.io/crates/v/statrs.svg)](https://crates.io/crates/statrs) @@ -13,18 +13,15 @@ Should work for both nightly and stable Rust. ## Description Statrs provides a host of statistical utilities for Rust scientific computing. -Included are a number of common distributions that can be sampled (i.e. Normal, Exponential, -Student's T, Gamma, Uniform, etc.) plus common statistical functions like the gamma function, -beta function, and error function. +Included are a number of common distributions that can be sampled (i.e. Normal, Exponential, Student's T, Gamma, Uniform, etc.) plus common statistical functions like the gamma function, beta function, and error function. -This library is a work-in-progress port of the statistical capabilities -in the C# Math.NET library. All unit tests in the library borrowed from Math.NET when possible -and filled-in when not. +This library is a work-in-progress port of the statistical capabilities in the C# Math.NET library. +All unit tests in the library borrowed from Math.NET when possible and filled-in when not. -This library is a work-in-progress and not complete. Planned for future releases are continued implementations -of distributions as well as porting over more statistical utilities +This library is a work-in-progress and not complete. +Planned for future releases are continued implementations of distributions as well as porting over more statistical utilities. -Please check out the documentation [here](https://docs.rs/statrs/*/statrs/) +Please check out the documentation [here](https://docs.rs/statrs/*/statrs/). ## Usage @@ -38,7 +35,7 @@ statrs = "0.16" ## Examples Statrs comes with a number of commonly used distributions including Normal, Gamma, Student's T, Exponential, Weibull, etc. -The common use case is to set up the distributions and sample from them which depends on the `Rand` crate for random number generation +The common use case is to set up the distributions and sample from them which depends on the `Rand` crate for random number generation. ```Rust use statrs::distribution::Exp; @@ -49,7 +46,7 @@ let n = Exp::new(0.5).unwrap(); print!("{}", n.sample(&mut r)); ``` -Statrs also comes with a number of useful utility traits for more detailed introspection of distributions +Statrs also comes with a number of useful utility traits for more detailed introspection of distributions. ```Rust use statrs::distribution::{Exp, Continuous, ContinuousCDF}; @@ -76,7 +73,8 @@ assert!(n.variance().is_none()); ## Contributing -Want to contribute? Check out some of the issues marked [help wanted](https://github.com/statrs-dev/statrs/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22) +Want to contribute? +Check out some of the issues marked [help wanted](https://github.com/statrs-dev/statrs/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22) ### How to contribute @@ -92,24 +90,28 @@ Create a feature branch: git checkout -b master ``` -After commiting your code: +Write your code and docs, then ensure it is formatted: + +The below sample modify in-place, use `--check` flag to view diff without making file changes. +Not using `fmt` from +nightly may result in some warnings and different formatting. +Our CI will `fmt`, but less chores in commit history are appreciated. ``` -git push -u origin +cargo +nightly fmt ``` -Then submit a PR, preferably referencing the relevant issue. +After commiting your code: -### Style +``` +git push -u origin +``` -This repo makes use of `rustfmt` with the configuration specified in `rustfmt.toml`. -See https://github.com/rust-lang-nursery/rustfmt for instructions on installation -and usage and run the formatter using `rustfmt --write-mode overwrite *.rs` in -the `src` directory before committing. +Then submit a PR, preferably referencing the relevant issue, if it exists. ### Commit messages Please be explicit and and purposeful with commit messages. +[Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/#summary) encouraged. #### Bad @@ -122,3 +124,8 @@ Modify test code ``` test: Update statrs::distribution::Normal test_cdf ``` + +### Communication Expectations + +Please allow at least one week before pinging issues/pr's. + From 63c6da9e2a3abbb61d1138e332483128f2f78524 Mon Sep 17 00:00:00 2001 From: Orion Yeung <11580988+orionyeung001@users.noreply.github.com> Date: Fri, 12 Apr 2024 17:43:59 -0500 Subject: [PATCH 6/7] chore: update badges and move examples to docs --- README.md | 45 +++++---------------------------------------- src/lib.rs | 46 +++++++++++++++++++++++++++++++++------------- 2 files changed, 38 insertions(+), 53 deletions(-) diff --git a/README.md b/README.md index c6e59dbb..fa43b7bb 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,10 @@ # statrs ![tests](https://github.com/statrs-dev/statrs/actions/workflows/test.yml/badge.svg) -[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE.md) -[![Crates.io](https://img.shields.io/crates/v/statrs.svg)](https://crates.io/crates/statrs) +[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE.md)] +[![Crate](https://img.shields.io/crates/v/statrs.svg)](https://crates.io/crates/statrs) +![docs.rs](https://img.shields.io/docsrs/statrs?style=for-the-badge). +[![codecov](https://codecov.io/gh/statrs-dev/statrs/graph/badge.svg?token=XtMSMYXvIf)](https://codecov.io/gh/statrs-dev/statrs) ## Current Version: v0.16.0 @@ -32,44 +34,7 @@ Add the most recent release to your `Cargo.toml` statrs = "0.16" ``` -## Examples - -Statrs comes with a number of commonly used distributions including Normal, Gamma, Student's T, Exponential, Weibull, etc. -The common use case is to set up the distributions and sample from them which depends on the `Rand` crate for random number generation. - -```Rust -use statrs::distribution::Exp; -use rand::distributions::Distribution; - -let mut r = rand::rngs::OsRng; -let n = Exp::new(0.5).unwrap(); -print!("{}", n.sample(&mut r)); -``` - -Statrs also comes with a number of useful utility traits for more detailed introspection of distributions. - -```Rust -use statrs::distribution::{Exp, Continuous, ContinuousCDF}; -use statrs::statistics::Distribution; - -let n = Exp::new(1.0).unwrap(); -assert_eq!(n.mean(), Some(1.0)); -assert_eq!(n.variance(), Some(1.0)); -assert_eq!(n.entropy(), Some(1.0)); -assert_eq!(n.skewness(), Some(2.0)); -assert_eq!(n.cdf(1.0), 0.6321205588285576784045); -assert_eq!(n.pdf(1.0), 0.3678794411714423215955); -``` - -as well as utility functions including `erf`, `gamma`, `ln_gamma`, `beta`, etc. - -```Rust -use statrs::statistics::Distribution; -use statrs::distribution::FisherSnedecor; - -let n = FisherSnedecor::new(1.0, 1.0).unwrap(); -assert!(n.variance().is_none()); -``` +For examples, view the docs hosted on ![docs.rs](https://img.shields.io/docsrs/statrs?style=for-the-badge). ## Contributing diff --git a/src/lib.rs b/src/lib.rs index 9a9d0a70..939400fb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -5,23 +5,43 @@ //! Math.NET in so far as they are used in the computation of distribution //! values. This crate depends on the `rand` crate to provide RNG. //! -//! # Example -//! The following example samples from a standard normal distribution -//! +//! # Sampling +//! The common use case is to set up the distributions and sample from them which depends on the `Rand` crate for random number generation. //! ``` -//! # extern crate rand; -//! # extern crate statrs; +//! use statrs::distribution::Exp; //! use rand::distributions::Distribution; -//! use statrs::distribution::Normal; +//! let mut r = rand::rngs::OsRng; +//! let n = Exp::new(0.5).unwrap(); +//! print!("{}", n.sample(&mut r)); +//! ``` +//! +//! # Introspecting distributions +//! Statrs also comes with a number of useful utility traits for more detailed introspection of distributions. +//! ``` +//! use statrs::distribution::{Exp, Continuous, ContinuousCDF}; // `cdf` and `pdf` +//! use statrs::statistics::Distribution; // statistical moments and entropy +//! +//! let n = Exp::new(1.0).unwrap(); +//! assert_eq!(n.mean(), Some(1.0)); +//! assert_eq!(n.variance(), Some(1.0)); +//! assert_eq!(n.entropy(), Some(1.0)); +//! assert_eq!(n.skewness(), Some(2.0)); +//! assert_eq!(n.cdf(1.0), 0.6321205588285576784045); +//! assert_eq!(n.pdf(1.0), 0.3678794411714423215955); +//! ``` +//! +//! # Utility functions +//! as well as utility functions including `erf`, `gamma`, `ln_gamma`, `beta`, etc. +//! +//! ``` +//! use statrs::distribution::FisherSnedecor; +//! use statrs::statistics::Distribution; //! -//! # fn main() { -//! let mut r = rand::thread_rng(); -//! let n = Normal::new(0.0, 1.0).unwrap(); -//! for _ in 0..10 { -//! print!("{}", n.sample(&mut r)); -//! } -//! # } +//! let n = FisherSnedecor::new(1.0, 1.0).unwrap(); +//! assert!(n.variance().is_none()); //! ``` +//! ## Distributions implemented +//! Statrs comes with a number of commonly used distributions including Normal, Gamma, Student's T, Exponential, Weibull, etc. view all implemented in `distributions` module. #![crate_type = "lib"] #![crate_name = "statrs"] From cecab1de6563ad8d24c479dfb9dc7064e8cd13a1 Mon Sep 17 00:00:00 2001 From: Orion Yeung <11580988+orionyeung001@users.noreply.github.com> Date: Sun, 21 Apr 2024 10:28:01 -0500 Subject: [PATCH 7/7] chore: consistent linefeed --- README.md | 190 +++++++++++++++++++++++++++--------------------------- 1 file changed, 95 insertions(+), 95 deletions(-) diff --git a/README.md b/README.md index fa43b7bb..90362c54 100644 --- a/README.md +++ b/README.md @@ -1,96 +1,96 @@ -# statrs - -![tests](https://github.com/statrs-dev/statrs/actions/workflows/test.yml/badge.svg) -[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE.md)] -[![Crate](https://img.shields.io/crates/v/statrs.svg)](https://crates.io/crates/statrs) -![docs.rs](https://img.shields.io/docsrs/statrs?style=for-the-badge). -[![codecov](https://codecov.io/gh/statrs-dev/statrs/graph/badge.svg?token=XtMSMYXvIf)](https://codecov.io/gh/statrs-dev/statrs) - -## Current Version: v0.16.0 - -Should work for both nightly and stable Rust. - -**NOTE:** While I will try to maintain backwards compatibility as much as possible, since this is still a 0.x.x project the API is not considered stable and thus subject to possible breaking changes up until v1.0.0 - -## Description - -Statrs provides a host of statistical utilities for Rust scientific computing. -Included are a number of common distributions that can be sampled (i.e. Normal, Exponential, Student's T, Gamma, Uniform, etc.) plus common statistical functions like the gamma function, beta function, and error function. - -This library is a work-in-progress port of the statistical capabilities in the C# Math.NET library. -All unit tests in the library borrowed from Math.NET when possible and filled-in when not. - -This library is a work-in-progress and not complete. -Planned for future releases are continued implementations of distributions as well as porting over more statistical utilities. - -Please check out the documentation [here](https://docs.rs/statrs/*/statrs/). - -## Usage - -Add the most recent release to your `Cargo.toml` - -```Rust -[dependencies] -statrs = "0.16" -``` - +# statrs + +![tests](https://github.com/statrs-dev/statrs/actions/workflows/test.yml/badge.svg) +[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE.md)] +[![Crate](https://img.shields.io/crates/v/statrs.svg)](https://crates.io/crates/statrs) +![docs.rs](https://img.shields.io/docsrs/statrs?style=for-the-badge). +[![codecov](https://codecov.io/gh/statrs-dev/statrs/graph/badge.svg?token=XtMSMYXvIf)](https://codecov.io/gh/statrs-dev/statrs) + +## Current Version: v0.16.0 + +Should work for both nightly and stable Rust. + +**NOTE:** While I will try to maintain backwards compatibility as much as possible, since this is still a 0.x.x project the API is not considered stable and thus subject to possible breaking changes up until v1.0.0 + +## Description + +Statrs provides a host of statistical utilities for Rust scientific computing. +Included are a number of common distributions that can be sampled (i.e. Normal, Exponential, Student's T, Gamma, Uniform, etc.) plus common statistical functions like the gamma function, beta function, and error function. + +This library is a work-in-progress port of the statistical capabilities in the C# Math.NET library. +All unit tests in the library borrowed from Math.NET when possible and filled-in when not. + +This library is a work-in-progress and not complete. +Planned for future releases are continued implementations of distributions as well as porting over more statistical utilities. + +Please check out the documentation [here](https://docs.rs/statrs/*/statrs/). + +## Usage + +Add the most recent release to your `Cargo.toml` + +```Rust +[dependencies] +statrs = "0.16" +``` + For examples, view the docs hosted on ![docs.rs](https://img.shields.io/docsrs/statrs?style=for-the-badge). - -## Contributing - -Want to contribute? -Check out some of the issues marked [help wanted](https://github.com/statrs-dev/statrs/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22) - -### How to contribute - -Clone the repo: - -``` -git clone https://github.com/statrs-dev/statrs -``` - -Create a feature branch: - -``` -git checkout -b master -``` - -Write your code and docs, then ensure it is formatted: - -The below sample modify in-place, use `--check` flag to view diff without making file changes. -Not using `fmt` from +nightly may result in some warnings and different formatting. -Our CI will `fmt`, but less chores in commit history are appreciated. - -``` -cargo +nightly fmt -``` - -After commiting your code: - -``` -git push -u origin -``` - -Then submit a PR, preferably referencing the relevant issue, if it exists. - -### Commit messages - -Please be explicit and and purposeful with commit messages. -[Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/#summary) encouraged. - -#### Bad - -``` -Modify test code -``` - -#### Good - -``` -test: Update statrs::distribution::Normal test_cdf -``` - -### Communication Expectations - -Please allow at least one week before pinging issues/pr's. - + +## Contributing + +Want to contribute? +Check out some of the issues marked [help wanted](https://github.com/statrs-dev/statrs/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22) + +### How to contribute + +Clone the repo: + +``` +git clone https://github.com/statrs-dev/statrs +``` + +Create a feature branch: + +``` +git checkout -b master +``` + +Write your code and docs, then ensure it is formatted: + +The below sample modify in-place, use `--check` flag to view diff without making file changes. +Not using `fmt` from +nightly may result in some warnings and different formatting. +Our CI will `fmt`, but less chores in commit history are appreciated. + +``` +cargo +nightly fmt +``` + +After commiting your code: + +``` +git push -u origin +``` + +Then submit a PR, preferably referencing the relevant issue, if it exists. + +### Commit messages + +Please be explicit and and purposeful with commit messages. +[Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/#summary) encouraged. + +#### Bad + +``` +Modify test code +``` + +#### Good + +``` +test: Update statrs::distribution::Normal test_cdf +``` + +### Communication Expectations + +Please allow at least one week before pinging issues/pr's. +