---
name: "wn_random_double_between"
section: "3"
platform: "linux"
package: "libwn-dev"
version: "6.0-17"
release: "Debian 4.0 (Etch)"
platforms: ["linux"]
url: "https://new.carta.tech/wnrndd"
---

# wn\_random\_double\_between(3)

random distribution

Part of [wnrndd(3)](/wnrndd/3.md).

## NAME

wn\_true\_with\_probability, wn\_random\_int\_between, wn\_random\_double\_between, wn\_flat\_distribution, wn\_normal\_distribution, wn\_exponential\_distribution, wn\_poisson\_distribution - random distribution

## SYNOPSIS

```
#include <wn/wnrndd.h>

bool wn_true_with_probability(double prob)

int wn_random_int_between(int low,int high)

double wn_random_double_between(double low,double high)

double wn_flat_distribution(void)

double wn_normal_distribution(void)

double wn_exponential_distribution(void)

int wn_poisson_distribution(double mean)
```

## DESCRIPTION

These routines generate random numbers with various probability distributions, using wnrnd.

**wn\_true\_with\_probability** returns (randomly) **TRUE** with probability *prob* and **FALSE** with probability 1-*prob*.

**wn\_random\_int\_between** returns a randomly chosen integer in the range \[*low*,*high*).  *low* is in the range; *high* is not.

**wn\_random\_double\_between** returns a randomly chosen double in the range (*low*,*high*).  It will never return *low* or *high*.

**wn\_flat\_distribution** is equivalent to  **wn\_random\_double\_between**(0.0,1,0)".

**wn\_normal\_distribution** returns a double randomly chosen according to a normal (gaussian) probability density with mean = 0 and standard deviation = 1.

**wn\_exponential\_distribution** returns a double randomly chosen according to an exponential probability density with mean = 1.  An exponential probability density function has values

p(x) = exp(-x)    for all x \>= 0

p(x) = 0          for all x \<  0

**wn\_poisson\_distribution** returns an integer randomly chosen according to a Poisson distribution with mean *mean*.

## SEE ALSO

wnrnd

## AUTHOR

Will Naylor
