# Struct rand_distr::Triangular

source · ```
pub struct Triangular<F>where
F: Float,
Standard: Distribution<F>,{ /* private fields */ }
```

## Expand description

The triangular distribution.

A continuous probability distribution parameterised by a range, and a mode (most likely value) within that range.

The probability density function is triangular. For a similar distribution
with a smooth PDF, see the `Pert`

distribution.

## Example

```
use rand_distr::{Triangular, Distribution};
let d = Triangular::new(0., 5., 2.5).unwrap();
let v = d.sample(&mut rand::thread_rng());
println!("{} is from a triangular distribution", v);
```

## Implementations§

source§### impl<F> Triangular<F>where
F: Float,
Standard: Distribution<F>,

### impl<F> Triangular<F>where F: Float, Standard: Distribution<F>,

source#### pub fn new(min: F, max: F, mode: F) -> Result<Triangular<F>, TriangularError>

#### pub fn new(min: F, max: F, mode: F) -> Result<Triangular<F>, TriangularError>

Set up the Triangular distribution with defined `min`

, `max`

and `mode`

.

## Trait Implementations§

source§### impl<F> Clone for Triangular<F>where
F: Float + Clone,
Standard: Distribution<F>,

### impl<F> Clone for Triangular<F>where F: Float + Clone, Standard: Distribution<F>,

source§#### fn clone(&self) -> Triangular<F>

#### fn clone(&self) -> Triangular<F>

Returns a copy of the value. Read more

1.0.0 · source§#### fn clone_from(&mut self, source: &Self)

#### fn clone_from(&mut self, source: &Self)

Performs copy-assignment from

`source`

. Read moresource§### impl<F> Debug for Triangular<F>where
F: Float + Debug,
Standard: Distribution<F>,

### impl<F> Debug for Triangular<F>where F: Float + Debug, Standard: Distribution<F>,

source§### impl<'de, F> Deserialize<'de> for Triangular<F>where
F: Float + Deserialize<'de>,
Standard: Distribution<F>,

### impl<'de, F> Deserialize<'de> for Triangular<F>where F: Float + Deserialize<'de>, Standard: Distribution<F>,

source§#### fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,

#### fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more

source§### impl<F> Distribution<F> for Triangular<F>where
F: Float,
Standard: Distribution<F>,

### impl<F> Distribution<F> for Triangular<F>where F: Float, Standard: Distribution<F>,

source§#### fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> F

#### fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> F

Generate a random value of

`T`

, using `rng`

as the source of randomness.source§### impl<F> PartialEq<Triangular<F>> for Triangular<F>where
F: Float + PartialEq,
Standard: Distribution<F>,

### impl<F> PartialEq<Triangular<F>> for Triangular<F>where F: Float + PartialEq, Standard: Distribution<F>,

source§#### fn eq(&self, other: &Triangular<F>) -> bool

#### fn eq(&self, other: &Triangular<F>) -> bool

This method tests for

`self`

and `other`

values to be equal, and is used
by `==`

.source§### impl<F> Serialize for Triangular<F>where
F: Float + Serialize,
Standard: Distribution<F>,

### impl<F> Serialize for Triangular<F>where F: Float + Serialize, Standard: Distribution<F>,

### impl<F> Copy for Triangular<F>where F: Float + Copy, Standard: Distribution<F>,

### impl<F> StructuralPartialEq for Triangular<F>where F: Float, Standard: Distribution<F>,

## Auto Trait Implementations§

### impl<F> RefUnwindSafe for Triangular<F>where F: RefUnwindSafe,

### impl<F> Send for Triangular<F>where F: Send,

### impl<F> Sync for Triangular<F>where F: Sync,

### impl<F> Unpin for Triangular<F>where F: Unpin,

### impl<F> UnwindSafe for Triangular<F>where F: UnwindSafe,

## Blanket Implementations§

source§### impl<T> BorrowMut<T> for Twhere
T: ?Sized,

### impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§#### fn borrow_mut(&mut self) -> &mut T

#### fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more