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:Google deepmind Mujoco mju Halton

From Leeroopedia
Knowledge Sources
Domains Numerical_Methods, Sampling
Last Updated 2026-02-15 06:00 GMT

Overview

Concrete tool for generating Halton low-discrepancy sequence values provided by the MuJoCo utility API.

Description

The mju_Halton function computes the n-th element of the Halton sequence in the given prime base. It reverses the base-representation digits of the index to produce a value in [0, 1) with low discrepancy.

Usage

Use for deterministic quasi-random sampling. Different prime bases (2, 3, 5, ...) generate independent sequences for multi-dimensional sampling.

Code Reference

Source Location

  • Repository: mujoco
  • File: src/engine/engine_util_misc.c
  • Lines: 1859-1872

Signature

mjtNum mju_Halton(int index, int base);

Import

#include <mujoco/mujoco.h>

I/O Contract

Inputs

Name Type Required Description
index int Yes Sequence index (0, 1, 2, ...)
base int Yes Prime base (2, 3, 5, 7, ...)

Outputs

Name Type Description
return mjtNum Value in [0, 1) from Halton sequence

Usage Examples

#include <mujoco/mujoco.h>

// Generate 2D quasi-random samples
for (int i = 0; i < 100; i++) {
    double x = mju_Halton(i, 2);  // base-2 for x dimension
    double y = mju_Halton(i, 3);  // base-3 for y dimension
    printf("Sample %d: (%f, %f)\n", i, x, y);
}

Related Pages

Implements Principle

Page Connections

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