Skip to content

Commit

Permalink
Embed more diagrams
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelOwenDyer committed Apr 10, 2024
1 parent 3187495 commit e4cfd9d
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 2 deletions.
Binary file modified rand_distr/plots/binomial.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified rand_distr/plots/chi_squared.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified rand_distr/plots/gamma.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added rand_distr/plots/normal.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed rand_distr/plots/standard_normal.png
Binary file not shown.
4 changes: 2 additions & 2 deletions rand_distr/src/binomial.rs
Expand Up @@ -33,8 +33,8 @@ use num_traits::Float;
///
/// # Diagram
///
/// The diagram shows the binomial distribution for `n = 10` and `p = 0.2`.
/// The probability of `k` successes is shown for each `k` from 0 to 10.
/// The following diagram of the binomial distribution illustrates the probability of
/// `k` successes out of `n = 10` trials with `p = 0.2` and `p = 0.6` for each `k` from 0 to `n`.
///
/// ![Binomial distribution][diagram]
#[cfg_attr(feature = "doc-images", doc = embed_doc_image::embed_image!("diagram", "plots/binomial.png"))]
Expand Down
7 changes: 7 additions & 0 deletions rand_distr/src/exponential.rs
Expand Up @@ -91,6 +91,13 @@ impl Distribution<f64> for Exp1 {
/// let v = exp.sample(&mut rand::thread_rng());
/// println!("{} is from a Exp(2) distribution", v);
/// ```
///
/// # Diagram
///
/// The diagram shows the exponential distribution with `λ = 0.5`, `λ = 1` and `λ = 2`.
///
/// ![Exponential distribution][diagram]
#[cfg_attr(feature = "doc-images", doc = embed_doc_image::embed_image!("diagram", "plots/exponential.png"))]
#[derive(Clone, Copy, Debug, PartialEq)]
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
pub struct Exp<F>
Expand Down
14 changes: 14 additions & 0 deletions rand_distr/src/gamma.rs
Expand Up @@ -50,10 +50,17 @@ use serde::{Serialize, Deserialize};
/// println!("{} is from a Gamma(2, 5) distribution", v);
/// ```
///
/// # Diagram
///
/// The diagram shows the Gamma distribution with varying shape and scale.
///
/// ![Gamma distribution][diagram]
///
/// [^1]: George Marsaglia and Wai Wan Tsang. 2000. "A Simple Method for
/// Generating Gamma Variables" *ACM Trans. Math. Softw.* 26, 3
/// (September 2000), 363-372.
/// DOI:[10.1145/358407.358414](https://doi.acm.org/10.1145/358407.358414)
#[cfg_attr(feature = "doc-images", doc = embed_doc_image::embed_image!("diagram", "plots/gamma.png"))]
#[derive(Clone, Copy, Debug, PartialEq)]
#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
pub struct Gamma<F>
Expand Down Expand Up @@ -280,6 +287,13 @@ where
/// let v = chi.sample(&mut rand::thread_rng());
/// println!("{} is from a χ²(11) distribution", v)
/// ```
///
/// # Diagram
///
/// The diagram shows the chi-squared distribution with varying degrees of freedom.
///
/// ![Chi-squared distribution][diagram]
#[cfg_attr(feature = "doc-images", doc = embed_doc_image::embed_image!("diagram", "plots/chi_squared.png"))]
#[derive(Clone, Copy, Debug, PartialEq)]
#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
pub struct ChiSquared<F>
Expand Down
7 changes: 7 additions & 0 deletions rand_distr/src/normal.rs
Expand Up @@ -36,6 +36,13 @@ use core::fmt;
/// let val: f64 = thread_rng().sample(StandardNormal);
/// println!("{}", val);
/// ```
///
/// # Diagram
///
/// The following diagram shows the normal distribution with various parameters.
///
/// ![Normal distribution][diagram]
#[cfg_attr(feature = "doc-images", doc = embed_doc_image::embed_image!("diagram", "plots/normal.png"))]
#[derive(Clone, Copy, Debug)]
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
pub struct StandardNormal;
Expand Down

0 comments on commit e4cfd9d

Please sign in to comment.