Skip to content
All library documents

Why PCG Can Suit Trading Simulations Better Than a Basic LCG

Article MQL5 code base

Summary

This document contrasts MQL’s built-in MathRand generator with a class wrapping a 32-bit PCG pseudorandom number generator. It characterizes MathRand as a limited linear congruential generator and says its statistical flaws make it unsuitable for large Monte Carlo simulations or other tasks requiring higher-quality randomness. PCG is presented as a fast, compact alternative that applies an output transformation to improve the behavior of low-order bits.

The class interface supports bounded integers and doubles, Boolean outcomes, and normally distributed values, with automatic or user-supplied seeds. The document mentions visual plots of generated values and low-order bits as evidence of random-looking patterns, but supplies no formal test results for this particular implementation or reproducibility guidance. The practical lesson is that simulation quality depends partly on the random-number generator; the text does not establish cryptographic security or guarantee that every simulation using PCG is statistically sound.

Key ideas

  • The document describes MathRand as a small-range linear congruential generator with statistical weaknesses.
  • It presents PCG as a fast generator with improved low-order bit behavior.
  • The class offers integer, decimal, Boolean, and normally distributed outputs.
  • Visual patterns are shown, but no detailed statistical validation of this implementation is provided.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.