| OpendTect 8.0

Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Stats::RandGen Class Reference
Algo

Uniform Random Generator Not thread-safe to preserve performance. In multi-threaded context, use one generator per thread. More...

`#include <statrand.h>`

Inheritance diagram for Stats::RandGen:
[legend]

## Public Member Functions
| RandGen ()
double | get () const override
| Uniform [0-1].
int | getIndex (int sz) const
| random index in the range [0,sz>
od_int64 | getIndex (od_int64 sz) const
| random index in the range [0,sz>
int | getIndexFast (int sz, int) const
od_int64 | getIndexFast (od_int64 sz, od_int64) const
int | getInt () const
| Uniform int.
int | getInt (int min, int max) const
| random int in the range [min,max]>
bool | init (int seed) override
| Not for production.
template<class ODSET >
void | subselect (ODSET &ods, od_int64 targetsz) const
template<class T >
void | subselect (T &, od_int64 targetsz) const
template<class T , class SzTp >
void | subselect (T *, SzTp sz, SzTp targetsz) const
Public Member Functions inherited from Stats::RandomGenerator
virtual | ~RandomGenerator ()

## Private Member Functions
| mOD_DisableCopy (RandGen)

## Private Attributes
std::mt19937_64 | gen64_
std::mt19937 | gen_
std::random_device | rd_
Threads::Atomic< int > | seedval_ = mUdf(int)

## Detailed Description

Uniform Random Generator Not thread-safe to preserve performance. In multi-threaded context, use one generator per thread.

<>

## Constructor & Destructor Documentation

## ◆ RandGen()

Stats::RandGen::RandGen | ( |  | ) |

## Member Function Documentation

## ◆ get()

double Stats::RandGen::get | ( |  | ) | const
| override virtual

Uniform [0-1].

Implements Stats::RandomGenerator.

## ◆ getIndex() [1/2]

int Stats::RandGen::getIndex | ( | int | sz | ) | const

random index in the range [0,sz>

## ◆ getIndex() [2/2]

od_int64 Stats::RandGen::getIndex | ( | od_int64 | sz | ) | const

random index in the range [0,sz>

## ◆ getIndexFast() [1/2]

int Stats::RandGen::getIndexFast | ( | int | sz,
|  | int | ) const
| inline

## ◆ getIndexFast() [2/2]

od_int64 Stats::RandGen::getIndexFast | ( | od_int64 | sz,
|  | od_int64 | ) const
| inline

## ◆ getInt() [1/2]

int Stats::RandGen::getInt | ( |  | ) | const

Uniform int.

## ◆ getInt() [2/2]

int Stats::RandGen::getInt | ( | int | min,
|  | int | max ) const

random int in the range [min,max]>

## ◆ init()

bool Stats::RandGen::init | ( | int | seed | ) |
| override virtual

Not for production.

Reimplemented from Stats::RandomGenerator.

## ◆ mOD_DisableCopy()

Stats::RandGen::mOD_DisableCopy | ( | RandGen |  | ) |
| private

## ◆ subselect() [1/3]

template<class ODSET >

void Stats::RandGen::subselect | ( | ODSET & | ods,
|  | od_int64 | targetsz ) const
| inline

## ◆ subselect() [2/3]

template<class T >

void Stats::RandGen::subselect | ( | T & | ,
|  | od_int64 | targetsz ) const

Does not preserve order The removed items will really be erased

## ◆ subselect() [3/3]

template<class T , class SzTp >

void Stats::RandGen::subselect | ( | T * | arr,
|  | SzTp | sz,
|  | SzTp | targetsz ) const
| inline

Does not preserve order. Afterwards, the 'removed' values occupy the indexes targetsz - maxsz-1

## Member Data Documentation

## ◆ gen64_

std::mt19937_64 Stats::RandGen::gen64_
| mutable private

## ◆ gen_

std::mt19937 Stats::RandGen::gen_
| mutable private

## ◆ rd_

std::random_device Stats::RandGen::rd_
| private

## ◆ seedval_

Threads::Atomic<int> Stats::RandGen::seedval_ = mUdf(int)
| private

Generated at
for the OpendTect seismic interpretation project. Copyright (C): dGB Beheer B.V. 1995-2025