CX Framework
Cross-platform C utility framework
Loading...
Searching...
No Matches
Random Number Generation

Modules

 Linear Congruential Generator (LCG)
 
 Initialization
 
 Random Number Generation
 
 State Manipulation
 

Data Structures

struct  PcgState
 

Typedefs

typedef struct PcgState PcgState
 

Detailed Description

Utilities for random number generation

The PCG (Permuted Congruential Generator) is a family of simple fast space-efficient statistically good algorithms for random number generation. PCG combines carefully chosen linear congruential generator with a permutation function to produce high-quality random output.

Key features:

Basic usage:

pcgAutoSeed(&rng); // Seed with cryptographic-quality entropy
uint32 val = pcgRandom(&rng); // Generate random uint32
uint32 dice = pcgRange(&rng, 1, 6); // Simulate a 6-sided die
bool coin = pcgFlip(&rng); // Flip a coin
bool pcgFlip(PcgState *rng)
uint32 pcgRange(PcgState *rng, uint32 lower, uint32 upper)
Definition pcg.h:166
uint32 pcgRandom(PcgState *rng)
void pcgAutoSeed(PcgState *rng)
Definition pcg.h:54

Typedef Documentation

◆ PcgState

typedef struct PcgState PcgState

PCG random number generator state

The internal state is private and should not be accessed directly. Always use the provided functions to manipulate and query the generator.