---
name: "std::geometric_distribution"
section: "3"
platform: "linux"
package: "gcc"
version: "16.2.1+r23+gd564253eb6c8-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/std::geometric_distribution"
---

# std::geometric\_distribution(3)

A discrete geometric random number distribution.

## NAME

std::geometric\_distribution\< \_IntType \> - A discrete geometric random number distribution.

## SYNOPSIS

\#include \<random\>

### Classes

struct **param\_type**\

### Public Types

typedef \_IntType **result\_type**\

### Public Member Functions

**geometric\_distribution** (const **param\_type** &\_\_p)\
 **geometric\_distribution** (double \_\_p)\
 template\<typename \_ForwardIterator, typename \_UniformRandomNumberGenerator\> void **\_\_generate** (\_ForwardIterator \_\_f, \_ForwardIterator \_\_t, \_UniformRandomNumberGenerator &\_\_urng)\
 template\<typename \_ForwardIterator, typename \_UniformRandomNumberGenerator\> void **\_\_generate** (\_ForwardIterator \_\_f, \_ForwardIterator \_\_t, \_UniformRandomNumberGenerator &\_\_urng, const **param\_type** &\_\_p)\
 template\<typename \_UniformRandomNumberGenerator\> void **\_\_generate** (**result\_type** \*\_\_f, **result\_type** \*\_\_t, \_UniformRandomNumberGenerator &\_\_urng, const **param\_type** &\_\_p)\
 **result\_type** **max** () const\
 Returns the least upper bound value of the distribution.  **result\_type** **min** () const\
 Returns the greatest lower bound value of the distribution.  template\<typename \_UniformRandomNumberGenerator\> **result\_type** **operator()** (\_UniformRandomNumberGenerator &\_\_urng)\
 Generating functions.  template\<typename \_UniformRandomNumberGenerator\> **result\_type** **operator()** (\_UniformRandomNumberGenerator &\_\_urng, const **param\_type** &\_\_p)\
 double **p** () const\
 Returns the distribution parameter p.  **param\_type** **param** () const\
 Returns the parameter set of the distribution.  void **param** (const **param\_type** &\_\_param)\
 Sets the parameter set of the distribution.  void **reset** ()\
 Resets the distribution state.

### Friends

bool **operator==** (const geometric\_distribution &\_\_d1, const geometric\_distribution &\_\_d2)\
 Return true if two geometric distributions have the same parameters.

## Detailed Description

### template\<typename \_IntType = int\>

class std::geometric\_distribution\< \_IntType \>"A discrete geometric random number distribution.

The formula for the geometric probability density function is $p(i\|p) = p(1 - p)^{i}$ where $p$ is the parameter of the distribution.

**Since**

C++11

## Member Typedef Documentation

### template\<typename \_IntType = int\> typedef \_IntType std::geometric\_distribution\< \_IntType \>::result\_type

The type of the range of the distribution.

## Member Function Documentation

### template\<typename \_IntType = int\> result\_type std::geometric\_distribution\< \_IntType \>::max () const \[inline\]

Returns the least upper bound value of the distribution.

### template\<typename \_IntType = int\> result\_type std::geometric\_distribution\< \_IntType \>::min () const \[inline\]

Returns the greatest lower bound value of the distribution.

### template\<typename \_IntType = int\> template\<typename \_UniformRandomNumberGenerator\> result\_type std::geometric\_distribution\< \_IntType \>::operator() (\_UniformRandomNumberGenerator & \_\_urng) \[inline\]

Generating functions.

Referenced by **operator()()**.

### template\<typename \_IntType = int\> double std::geometric\_distribution\< \_IntType \>::p () const \[inline\]

Returns the distribution parameter p.

### template\<typename \_IntType = int\> param\_type std::geometric\_distribution\< \_IntType \>::param () const \[inline\]

Returns the parameter set of the distribution.

Referenced by **std::operator\>\>()**.

### template\<typename \_IntType = int\> void std::geometric\_distribution\< \_IntType \>::param (const param\_type & \_\_param) \[inline\]

Sets the parameter set of the distribution.

**Parameters**

*\_\_param* The new parameter set of the distribution.

### template\<typename \_IntType = int\> void std::geometric\_distribution\< \_IntType \>::reset () \[inline\]

Resets the distribution state. Does nothing for the geometric distribution.

## Friends And Related Symbol Documentation

### template\<typename \_IntType = int\> bool operator== (const geometric\_distribution\< \_IntType \> & \_\_d1, const geometric\_distribution\< \_IntType \> & \_\_d2) \[friend\]

Return true if two geometric distributions have the same parameters.

## Author

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