Skip to main content

tklds — High-Dimensional Sobol’ Sequences for Python

PyPI Python License

tklds (Tenokonda Low Discrepancy Sequences) is a Python package and direction-number dataset for generating, scrambling, and evaluating high-dimensional Sobol’ sequences for quasi-Monte Carlo (QMC) simulation.

The package includes the tkrg-a-ap5 direction-number set for 50,000 dimensions. The construction satisfies Property A in every supported dimension and Property A′ on every block of five adjacent dimensions. It also includes the new-joe-kuo-6.21201 direction numbers for reference and comparison.

The library provides:

  • batch and iterative Sobol’ point generation;
  • a SciPy-compatible SobolEngine with optional scrambling;
  • the tkrg-a-ap5 and new-joe-kuo-6.21201 direction-number datasets;
  • diagnostics for high-dimensional sequence behaviour;
  • worked notebooks for integration, stochastic processes, pricing, sensitivities, and risk; and
  • reproducibility material for the accompanying 2026 paper.

Scope note: Direction-number performance depends on the integrand, coordinate ordering, path construction, scrambling method, and sample size. The supplied research benchmarks identify material advantages for the tested high-dimensional path-simulation regimes; they do not establish that one direction-number set dominates every QMC problem.

Install

From PyPI

python -m pip install tklds

From a source checkout

git clone https://github.com/TENOKONDA/tklds.git
cd tklds
python -m pip install .

Editable development installation

git clone https://github.com/TENOKONDA/tklds.git
cd tklds
python -m pip install -e ".[examples,test]"

tklds requires Python 3.10 or later. The examples extra installs the packages used by the notebooks; the test extra installs the proposed test runner and coverage tooling.

Quick start

Generate a batch of Sobol’ points

from tklds.constant import SequenceNum
from tklds.interface.generators import generate_lds_rvs

points = generate_lds_rvs(
    sequence=SequenceNum.TKRG_A_AP5,
    n=1_024,
    d=32,
    skip=0,
)

print(points.shape)  # (1024, 32)

Use the SciPy-compatible engine

from tklds.constant import SequenceNum
from tklds.interface.generators import create_sobol_lds_engine

engine = create_sobol_lds_engine(
    sequence=SequenceNum.TKRG_A_AP5,
    d=256,
    scramble=True,
    seed=1234,
)

# 2**10 points. Power-of-two sample sizes preserve the natural
# balance properties of a Sobol’ digital net.
points = engine.random_base2(m=10)
print(points.shape)  # (1024, 256)

Generate points iteratively

from tklds.constant import SequenceNum
from tklds.interface.generators import create_iterative_lds_generator

sequence = create_iterative_lds_generator(
    sequence=SequenceNum.TKRG_A_AP5,
    d=8,
)

first_batch = sequence.rvs(size=(16, 8))
second_batch = sequence.rvs(size=(16, 8))

Available direction-number sets

Identifier Direction-number set Supported dimensions Intended use
SequenceNum.TKRG_A_AP5 tkrg-a-ap5 50,000 Default high-dimensional Sobol’ construction supplied by tklds
SequenceNum.NEW_JOE_KUO new-joe-kuo-6.21201 21,201 Established reference construction and compatibility comparisons

The raw direction-number files are distributed with the package under tklds/direction_numbers.

Choosing a generation method

Use generate_lds_rvs for a direct array of points, create_iterative_lds_generator when points are consumed in successive batches, and create_sobol_lds_engine when interoperability with the SciPy QMC interface is useful.

For deterministic Sobol’ experiments, use scramble=False. For replicate-based error estimation, use independent scrambled engines with controlled seeds. Where the balance properties of the underlying digital net matter, prefer n = 2**m and random_base2(m).

Examples and reproducibility

The repository separates introductory examples from paper-specific reproduction material:

Notebook dependencies are installed with:

python -m pip install -e ".[examples]"

Research basis

The current technical reference is:

Andres Oliva Denis, James Wheeldon, Ilya Manyakin, and Adrien Papaioannou. Sobol Direction Numbers for Quasi-Monte Carlo Simulation: Construction, Pathwise Dependence Diagnostics, and Financial Pricing Benchmarks. Tenokonda UK, 30 April 2026. SSRN abstract 7040539.

The paper introduces tkrg-a-ap5, explains its construction over GF(2), develops a pathwise dependence diagnostic, and reports deterministic pricing and risk benchmarks under standard chronological discretisation.

Testing

The repository contains unit tests for the public generator interfaces, iterative generation, the SciPy-compatible Sobol engine, numerical integration utilities, stochastic-process components, and the spurious-variance diagnostic.

Run the current suite from a source checkout with:

python -m unittest discover -s tklds/tests -p "test_*.py"

Automated pull-request and release-gating workflows are a high-priority follow-on item. Until those workflows are added, maintainers should run the complete suite manually before tagging a release.

Licence

tklds is distributed under the BSD 3-Clause License.

Metadata

Release files for tklds 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tklds 0.2.0
File Size Uploaded Provenance Actions
tklds-0.2.0.tar.gz 5.1 MB With provenance Details for tklds-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for tklds 0.2.0
File Interpreter ABI Platform Actions
tklds-0.2.0-py3-none-any.whl Python 3 none any Details for tklds-0.2.0-py3-none-any.whl

Total release size: 10.3 MB

Release files / tklds-0.2.0.tar.gz

Download URL tklds-0.2.0.tar.gz
Size 5.1 MB
Tags Source
SHA-256 checksum
How to use checksums
b52511488ae851532cb098380759398aea3576539df14351a6e2e5b0a038932f
BLAKE2b-256 checksum
How to use checksums
6d56a99e945bd7d83cab151be92e4a3f63773b209025469016fe738347df39da
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 24, 2026.

Transparency log

Release files / tklds-0.2.0-py3-none-any.whl

Download URL tklds-0.2.0-py3-none-any.whl
Size 5.2 MB
Tags Python 3
SHA-256 checksum
How to use checksums
9986f5dee4ee23a7d7cc584323d6324a5c5fe0daf764fc3484a31939153a4297
BLAKE2b-256 checksum
How to use checksums
5fbbfb4df5147711ffe717f746e385612c38f8f4a26302898d50ecdb06ee1e63
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 24, 2026.

Transparency log

Security for tklds 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for tklds-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 24, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page