Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Interpretml Interpret Random

From Leeroopedia


Knowledge Sources
Domains Machine_Learning, EBM_Core
Last Updated 2026-02-07 12:00 GMT

Overview

Implements the public C API functions for random number generation: MeasureRNG, InitRNG, CopyRNG, BranchRNG, GenerateSeed, and GenerateGaussianRandom.

Description

The random.cpp file provides the public C API entry points for the EBM random number generation subsystem. MeasureRNG returns the size of the RandomDeterministic struct for external allocation. InitRNG initializes an RNG from a seed. CopyRNG does a memcpy of the state. BranchRNG creates a new independent RNG by generating a seed from an existing one. GenerateSeed produces a single random seed, optionally using a non-deterministic source (std::random_device) when no RNG is provided. GenerateGaussianRandom generates normally-distributed random values using a GaussianDistribution helper, supporting both deterministic (from an RNG state) and non-deterministic (from std::random_device) modes. The Gaussian generation is used for differential privacy noise injection.

Usage

Called from the Python layer to manage RNG state for reproducible experiments. The Gaussian random generation is used for differential privacy when noise needs to be added to gradients or model outputs.

Code Reference

Source Location

Signature

EBM_API_BODY IntEbm EBM_CALLING_CONVENTION MeasureRNG(void);

EBM_API_BODY void EBM_CALLING_CONVENTION InitRNG(SeedEbm seed, void* rngOut);

EBM_API_BODY void EBM_CALLING_CONVENTION CopyRNG(void* rng, void* rngOut);

EBM_API_BODY void EBM_CALLING_CONVENTION BranchRNG(void* rng, void* rngOut);

EBM_API_BODY ErrorEbm EBM_CALLING_CONVENTION GenerateSeed(void* rng, SeedEbm* seedOut);

EBM_API_BODY ErrorEbm EBM_CALLING_CONVENTION GenerateGaussianRandom(
    void* rng, double stddev, IntEbm count, double* randomOut);

I/O Contract

Function Input Output
MeasureRNG (none) Size of RandomDeterministic in bytes
InitRNG seed, rngOut buffer Initialized RNG state
CopyRNG rng state, rngOut buffer Copied RNG state
BranchRNG parent rng, rngOut buffer New independent RNG state
GenerateSeed optional rng Random SeedEbm value
GenerateGaussianRandom optional rng, stddev, count Array of Gaussian random doubles

Usage Examples

# Called internally via native bindings
from interpret.glassbox import ExplainableBoostingClassifier
ebm = ExplainableBoostingClassifier(random_state=42)
ebm.fit(X, y)  # RNG API manages deterministic randomness for reproducibility

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment