`pub struct Geometric { /* private fields */ }`

## Expand description

The geometric distribution `Geometric(p)`

.

This is the probability distribution of the number of failures
(bounded to `[0, u64::MAX]`

) before the first success in a
series of `Bernoulli`

trials, where the
probability of success on each trial is `p`

.

This is the discrete analogue of the exponential distribution.

See `StandardGeometric`

for an optimised
implementation for `p = 0.5`

.

## §Density function

`f(k) = (1 - p)^k p`

for `k >= 0`

.

## §Plot

The following plot illustrates the geometric distribution for various
values of `p`

. Note how higher `p`

values shift the distribution to
the left, and the mean of the distribution is `1/p`

.

## §Example

```
use rand_distr::{Geometric, Distribution};
let geo = Geometric::new(0.25).unwrap();
let v = geo.sample(&mut rand::rng());
println!("{} is from a Geometric(0.25) distribution", v);
```

## Implementations§

## Trait Implementations§

Source§### impl<'de> Deserialize<'de> for Geometric

### impl<'de> Deserialize<'de> for Geometric

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 Distribution<u64> for Geometric

### impl Distribution<u64> for Geometric

### impl Copy for Geometric

### impl StructuralPartialEq for Geometric

## Auto Trait Implementations§

### impl Freeze for Geometric

### impl RefUnwindSafe for Geometric

### impl Send for Geometric

### impl Sync for Geometric

### impl Unpin for Geometric

### impl UnwindSafe for Geometric

## 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

Source§### impl<T> CloneToUninit for Twhere
T: Clone,

### impl<T> CloneToUninit for Twhere
T: Clone,

Source§#### unsafe fn clone_to_uninit(&self, dst: *mut T)

#### unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (

`clone_to_uninit`

)