---
name: "std::tr1::bernoulli_distribution"
section: "3cxx"
platform: "linux"
package: "libstdc++6-4.4-doc"
version: "4.4.5-8"
release: "Debian 6.0 (Squeeze)"
platforms: ["linux"]
url: "https://new.carta.tech/std::tr1::bernoulli_distribution/3cxx"
---

# std::tr1::bernoulli\_distribution(3cxx)

A Bernoulli random number distribution.

## NAME

std::tr1::bernoulli\_distribution -

A Bernoulli random number distribution.

## SYNOPSIS

### Public Types

typedef int **input\_type**\
 typedef bool **result\_type**\

### Public Member Functions

**bernoulli\_distribution** (double \_\_p=0.5)\
 template\<class \_UniformRandomNumberGenerator \> result\_type **operator()** (\_UniformRandomNumberGenerator &\_\_urng)\
 double **p** () const \
 void **reset** ()\

### Friends

template\<typename \_CharT , typename \_Traits \> **std::basic\_ostream**\< \_CharT, \_Traits \> & **operator\<\<** (**std::basic\_ostream**\< \_CharT, \_Traits \> &\_\_os, const **bernoulli\_distribution** &\_\_x)\
 template\<typename \_CharT , typename \_Traits \> **std::basic\_istream**\< \_CharT, \_Traits \> & **operator\>\>** (**std::basic\_istream**\< \_CharT, \_Traits \> &\_\_is, **bernoulli\_distribution** &\_\_x)\

## Detailed Description

A Bernoulli random number distribution.

Generates a sequence of true and false values with likelihood $ p $ that true will come up and $ (1 - p) $ that false will appear.

Definition at line 1688 of file tr1\_impl/random.

## Constructor & Destructor Documentation

### std::tr1::bernoulli\_distribution::bernoulli\_distribution (double \_\_p = `0.5`)` [inline, explicit]` Constructs a Bernoulli distribution with likelihood `p`.

**Parameters:**

*\_\_p* \[IN\] The likelihood of a true result being returned. Must be in the interval $ \[0, 1\] $.

Definition at line 1702 of file tr1\_impl/random.

## Member Function Documentation

### template\<class \_UniformRandomNumberGenerator \> result\_type std::tr1::bernoulli\_distribution::operator() (\_UniformRandomNumberGenerator & \_\_urng)` [inline]` Gets the next value in the Bernoullian sequence.

Definition at line 1728 of file tr1\_impl/random.

### double std::tr1::bernoulli\_distribution::p () const` [inline]` Gets the `p` parameter of the distribution.

Definition at line 1712 of file tr1\_impl/random.

### void std::tr1::bernoulli\_distribution::reset ()` [inline]` Resets the distribution state.

Does nothing for a Bernoulli distribution.

Definition at line 1721 of file tr1\_impl/random.

## Friends And Related Function Documentation

### template\<typename \_CharT , typename \_Traits \> std::basic\_ostream\<\_CharT, \_Traits\>& operator\<\< (std::basic\_ostream\< \_CharT, \_Traits \> & \_\_os, const bernoulli\_distribution & \_\_x)` [friend]` Inserts a bernoulli\_distribution random number distribution `__x` into the output stream `__os`.

**Parameters:**

*\_\_os* An output stream. \
 *\_\_x* A bernoulli\_distribution random number distribution.

**Returns:**

The output stream with the state of `__x` inserted or in an error state.

Definition at line 823 of file random.tcc.

### template\<typename \_CharT , typename \_Traits \> std::basic\_istream\<\_CharT, \_Traits\>& operator\>\> (std::basic\_istream\< \_CharT, \_Traits \> & \_\_is, bernoulli\_distribution & \_\_x)` [friend]` Extracts a bernoulli\_distribution random number distribution `__x` from the input stream `__is`.

**Parameters:**

*\_\_is* An input stream. \
 *\_\_x* A bernoulli\_distribution random number generator engine.

**Returns:**

The input stream with `__x` extracted or in an error state.

Definition at line 1761 of file tr1\_impl/random.

## Author

Generated automatically by Doxygen for libstdc++ from the source code.
