# Struct rand_distr::Triangular

source · `pub struct Triangular<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>

### impl<F> Triangular<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>

### impl<F> Clone for Triangular<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>

### impl<F> Debug for Triangular<F>

source§### impl<'de, F> Deserialize<'de> for Triangular<F>

### impl<'de, F> Deserialize<'de> for Triangular<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>

### impl<F> Distribution<F> for Triangular<F>

source§### impl<F> PartialEq for Triangular<F>

### impl<F> PartialEq for Triangular<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>

### impl<F> Serialize for Triangular<F>

### impl<F> Copy for Triangular<F>

### impl<F> StructuralPartialEq for Triangular<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