Skip to main content

Typing SVG


Python License PyPI Platform


Stats Entropy Hash C++


PyTorch TensorFlow JAX CuPy


NumPy Pandas Polars Dask


Tests Coverage Downloads



📌 The Problem

Pseudo-random number generators (PRNGs) like Mersenne Twister and Python's random are recursive:

xₙ₊₁ = (a·xₙ + c) mod m

This creates:

  • 🔁 Hidden correlations — each number depends on the one before
  • 📅 Periodicity — sequences eventually repeat
  • 🧱 Exploration boundaries — AI can't truly explore
  • 🎭 False reproducibility — same seed = same path

AI deserves better.


🎯 The Solution: Aleam

import aleam as al

rng = al.Aleam()
x = rng.random()  # True randomness. No recursion. No state.

Aleam implements the proven equation:

Ψ(t) = BLAKE2s( (Φ × Ξ(t)) ⊕ τ(t) )
Symbol Meaning
Φ Golden ratio prime (0x9E3779B97F4A7C15)
Ξ(t) 64-bit true entropy from system CSPRNG
τ(t) Nanosecond timestamp
⊕ XOR mixing
BLAKE2s Cryptographic hash

Properties:

🔄 Non-recursive 🎲 Stateless 🔒 Cryptographically Secure 🧠 AI-Optimized
Each call independent No seeds, no state Powered by BLAKE2s Gradient noise, latent sampling

🔬 How It Works

Aleam Core Algorithm

The Core Equation in Detail

Step Operation Description
1 Ξ(t) = get_entropy_64() Pull 64-bit true entropy from system
2 Ω = Φ × Ξ(t) Golden ratio mixing (bijective, maximally equidistributed)
3 τ = time.time_ns() Nanosecond timestamp for uniqueness
4 Σ = Ω ⊕ τ XOR mixing over 64 bits
5 ψ = BLAKE2s(Σ) Cryptographic hash to 64-bit output
6 r = ψ / 2⁶⁴ Map to floating point [0, 1)

⚡ Performance: CPU vs GPU

Aleam CPU vs GPU

Metric CPU (Python) CPU (C++ Core) GPU (CuPy)
Speed Coming soon Coming soon Coming soon
vs Python Coming soon Coming soon Coming soon
Time for 1B numbers Coming soon Coming soon Coming soon

Benchmarks pending - will be updated after Colab testing

💡 Key Insight: The C++ migration delivers significant CPU speedup over pure Python, while GPU acceleration provides massive parallel performance.


📊 Statistical Validation

After 2.55 million samples, Aleam passed all 10 rigorous tests:

Test Result Status
Mean 0.499578 ✓
Variance 0.083154 ✓
Chi-Square (Uniformity) 21.40 (critical 30.14) ✓ PASS
Max Autocorrelation 0.0094 ✓ EXCELLENT
π Estimation Error 0.0105% ✓ EXCELLENT
Shannon Entropy 0.9999 ✓ NEAR-PERFECT

"True randomness is not a bug — it's a feature."


🚀 Quick Start

pip install aleam

Install from source

git clone https://github.com/fardinsabid/aleam.git
cd aleam
pip install .

Basic Usage

import aleam as al

# Create a true random generator
rng = al.Aleam()

# Core randomness
x = rng.random()                    # 0.90324326
u64 = rng.random_uint64()           # 12345678901234567890
y = rng.randint(1, 100)             # 86
z = rng.choice(['AI', 'ML', 'Aleam'])  # 'ML'
u = rng.uniform(5.0, 10.0)          # 7.234
n = rng.gauss(0.0, 1.0)            # -0.432

# Sampling (requires list, not range)
population = list(range(10000))
batch = rng.sample(population, 64)  # Random 64 unique indices

# Shuffle list in-place
items = [1, 2, 3, 4, 5]
rng.shuffle(items)                  # [3, 1, 5, 2, 4]

# Random bytes for cryptography
key = rng.random_bytes(32)          # 32 cryptographically secure bytes

✨ Features

🎲 Core Randomness

Method Description Example
random() True random float in [0, 1) rng.random()
random_uint64() True random 64-bit integer rng.random_uint64()
randint(a, b) Random integer in [a, b] rng.randint(1, 100)
choice(seq) Random element from sequence rng.choice(['a', 'b', 'c'])
shuffle(lst) Shuffle list in-place rng.shuffle(my_list)
sample(pop, k) Sample k unique elements rng.sample(list(range(100)), 10)
random_bytes(n) Generate n random bytes rng.random_bytes(32)

📈 Statistical Distributions

Distribution Method Example
Uniform uniform(low, high) rng.uniform(5, 10)
Normal (Gaussian) gauss(mu, sigma) rng.gauss(0, 1)
Exponential exponential(rate) rng.exponential(1.0)
Beta beta(alpha, beta) rng.beta(2, 5)
Gamma gamma(shape, scale) rng.gamma(2, 1)
Poisson poisson(lam) rng.poisson(3.5)
Laplace laplace(loc, scale) rng.laplace(0, 1)
Logistic logistic(loc, scale) rng.logistic(0, 1)
Log-Normal lognormal(mu, sigma) rng.lognormal(0, 1)
Weibull weibull(shape, scale) rng.weibull(1.5, 1)
Pareto pareto(alpha, scale) rng.pareto(2, 1)
Chi-square chi_square(df) rng.chi_square(5)
Student's t student_t(df) rng.student_t(3)
F-distribution f_distribution(df1, df2) rng.f_distribution(5, 10)
Dirichlet dirichlet(alpha) rng.dirichlet([1, 2, 3])

🧠 AI/ML Features

Class Methods Use Case
AIRandom gradient_noise(), latent_vector(), dropout_mask(), augmentation_params(), mini_batch(), exploration_noise() Training, augmentation, RL exploration
GradientNoise add_noise(), reset(), current_scale() Gradient noise injection with decay
LatentSampler sample(), sample_one(), interpolate() Latent space sampling for VAEs/GANs

🔢 Array Operations

Function Description Example
random_array(shape) Uniform random array al.random_array((100, 100))
randn_array(shape, mu, sigma) Normal random array al.randn_array(1000, 0, 1)
randint_array(shape, low, high) Integer random array al.randint_array((50,), 0, 10)
choice_array(a, size, replace, p) Weighted sampling al.choice_array(fruits, size=100, p=weights)

🔌 Framework Integrations

PyTorch

import torch
import aleam as al

gen = al.TorchGenerator(device='cuda' if torch.cuda.is_available() else 'cpu')
tensor = gen.randn(100, 100)      # True random tensor on GPU
tensor = gen.rand(100, 100)       # Uniform [0, 1) tensor
tensor = gen.randint(0, 10, (100, 100))  # Integer tensor

TensorFlow

import tensorflow as tf
import aleam as al

gen = al.TFGenerator()
tensor = gen.normal((100, 100), mean=0, stddev=1)
tensor = gen.uniform((100, 100), minval=0, maxval=1)
tensor = gen.randint((100, 100), minval=0, maxval=10)

JAX

import jax
import aleam as al

gen = al.JAXGenerator()
key = gen.key()                   # True random key
tensor = jax.random.normal(key, (100, 100))

CuPy (Fastest GPU)

import cupy as cp
import aleam as al

gen = al.CuPyGenerator()
arr = gen.randn((10000, 10000))   # True random on GPU
arr = gen.random((10000, 10000))  # Uniform on GPU
arr = gen.randint((10000, 10000), 0, 10)

Pandas

import pandas as pd
import aleam as al

gen = al.PandasGenerator()
series = gen.series(1000, distribution="normal", params="mu=0,sigma=1")
df = gen.dataframe(1000, columns=['a', 'b', 'c'])
shuffled = gen.shuffle(df)

NumPy

import aleam as al
import numpy as np

# Direct array generation
arr = al.random_array((100, 100))      # Returns list, convert to numpy if needed
np_arr = np.array(arr)

# Or use module-level functions
arr = al.random_array((1000,))          # 1D array
matrix = al.random_array((10, 10))      # 2D matrix
norm_arr = al.randn_array(1000, 0, 1)   # Normal distribution
int_arr = al.randint_array((50,), 0, 10) # Integers

⚡ CUDA Acceleration

Aleam provides GPU acceleration through multiple backends:

Method Speed
CPU (Python) Coming soon
CPU (C++ Core) Coming soon
CuPy GPU Coming soon
PyTorch CUDA Coming soon
TensorFlow GPU Coming soon
JAX GPU Coming soon
import aleam as al

# Automatic GPU acceleration (auto-detects best backend)
cuda_gen = al.CUDAGenerator()

# Generate true random numbers on GPU
cupy_arr = cuda_gen.cupy_random((10000, 10000))

# Or use with specific frameworks
torch_tensor = cuda_gen.torch_randn(10000, 10000, device='cuda')
tf_tensor = cuda_gen.tf_random_normal((10000, 10000))

📦 Installation Details

pip install aleam

With Framework Support

# PyTorch
pip install aleam[torch]

# TensorFlow
pip install aleam[tensorflow]

# JAX
pip install aleam[jax]

# CuPy (for maximum GPU speed)
pip install aleam[cupy]

# Data science
pip install aleam[pandas]

# All frameworks
pip install aleam[all]

From Source (for development)

git clone https://github.com/fardinsabid/aleam.git
cd aleam
pip install .

Development Installation

pip install -e .[dev]

📁 Project Structure

aleam/
│
├── .github/
│   └── workflows/
│       ├── tests.yml
│       ├── publish.yml
│       ├── security.yml
│       └── docs.yml
│
├── aleam/
│   │
│   ├── __init__.py
│   └── py.typed
│
├── src/
│   │
│   └── aleam/
│       │
│       ├── bindings/
│       │   ├── module.cpp
│       │   └── exports.h
│       │
│       ├── core/
│       │   ├── aleam_core.h
│       │   ├── aleam_core.cpp
│       │   ├── constants.h
│       │   └── utils.h
│       │
│       ├── entropy/
│       │   ├── entropy.h
│       │   ├── entropy_linux.h
│       │   ├── entropy_windows.h
│       │   └── entropy_darwin.h
│       │
│       ├── hash/
│       │   ├── blake2s.h
│       │   └── blake2s_config.h
│       │
│       ├── distributions/
│       │   ├── distributions.h
│       │   ├── distributions.cpp
│       │   ├── normal.h
│       │   ├── exponential.h
│       │   ├── beta.h
│       │   ├── gamma.h
│       │   ├── poisson.h
│       │   ├── laplace.h
│       │   ├── logistic.h
│       │   ├── lognormal.h
│       │   ├── weibull.h
│       │   ├── pareto.h
│       │   ├── chi_square.h
│       │   ├── student_t.h
│       │   ├── f_distribution.h
│       │   └── dirichlet.h
│       │
│       ├── arrays/
│       │   ├── arrays.h
│       │   ├── arrays.cpp
│       │   └── array_utils.h
│       │
│       ├── ai/
│       │   ├── ai.h
│       │   ├── ai.cpp
│       │   ├── gradient_noise.h
│       │   ├── latent_sampler.h
│       │   └── augmentation.h
│       │
│       ├── integrations/
│       │   ├── integrations.h
│       │   ├── integrations.cpp
│       │   ├── torch_integration.h
│       │   ├── torch_integration.cpp
│       │   ├── tensorflow_integration.h
│       │   ├── tensorflow_integration.cpp
│       │   ├── jax_integration.h
│       │   ├── jax_integration.cpp
│       │   ├── cupy_integration.h
│       │   ├── cupy_integration.cpp
│       │   ├── pandas_integration.h
│       │   ├── pandas_integration.cpp
│       │   ├── polars_integration.h
│       │   ├── polars_integration.cpp
│       │   ├── xarray_integration.h
│       │   ├── xarray_integration.cpp
│       │   ├── pymc_integration.h
│       │   ├── pymc_integration.cpp
│       │   ├── dask_integration.h
│       │   └── dask_integration.cpp
│       │
│       └── cuda/
│           ├── cuda_kernels.h
│           ├── cuda_kernels.cu
│           ├── cuda_uniform.cu
│           ├── cuda_normal.cu
│           └── cuda_utils.h
│
├── include/
│   └── aleam/
│       └── aleam.h
│
├── tests/
│   ├── test_core.py
│   ├── test_ai.py
│   └── test_statistical.py
│
├── benchmarks/
│   └── benchmark_core.py
│
├── assets/
│   └── images/
│       ├── benchmarks/
│       │   ├── aleam_gpu_vs_lavarand_hd.png
│       │   └── cpu_vs_gpu.png
│       └── diagrams/
│            └── algorithm.png
│
│           
├── examples/
│   ├── basic_usage.py
│   ├── ai_ml_features.py
│   ├── array_operations.py
│   ├── distributions.py
│   ├── monte_carlo_pi.py
│   ├── reinforcement_learning.py
│   ├── cuda_integration.py
│   ├── pytorch_integration.py
│   └── tensorflow_integration.py
│
├── docs/
│   ├── ALEAM_RESEARCH_PAPER.md
│   └── index.md
│
├── setup.py
├── pyproject.toml
├── MANIFEST.in
├── requirements.txt
├── requirements-dev.txt
├── LICENSE
├── README.md
├── CONTRIBUTING.md
└── .gitignore

🔧 Troubleshooting

Q: Why is Aleam slower than random.random on CPU?

A: True randomness is slower than pseudo-random with the C++ core — that's expected. You're trading speed for genuine entropy. On GPU, Aleam achieves massive parallel performance.

Q: Can I seed Aleam for reproducible results?

A: No. Aleam is stateless by design. Call al.seed_free() to see the explanation. Use Python's random module if you need reproducibility.

Q: Is Aleam cryptographically secure?

A: Yes. Each call consumes 64 bits of true entropy and passes through BLAKE2s, a cryptographic hash.

Q: Does Aleam support GPU?

A: Yes! PyTorch, TensorFlow, JAX, and CuPy integrations all support GPU acceleration. Use al.CUDAGenerator() for automatic backend detection.

Q: Why does sample() require a list?

A: The C++ bindings accept Python lists directly. Use list(range(10000)) instead of range(10000).

Q: Will Aleam work on my platform?

A: Yes! Linux (getrandom), Windows (BCrypt), and macOS (arc4random) are all supported.


🔒 Responsible Use

  • ✅ Use for AI research, exploration, and creative projects
  • ✅ Use for scientific simulations requiring true randomness
  • ✅ Use for cryptographic applications
  • ❌ Do not use for security-critical systems without additional entropy sources
  • ❌ Do not use to generate deceptive or harmful content

📄 License

MIT License — see LICENSE for details.

Component License
Aleam Interface MIT
Core Algorithm MIT
BLAKE2s Public Domain / CC0

📦 PyPI pypi.org/project/aleam
🐛 Issues GitHub Issues
📖 Documentation GitHub Docs
📄 Research Paper ALEAM_RESEARCH_PAPER.md

🙏 Acknowledgments

  • BLAKE2 team for the cryptographic hash function
  • Open-source community for entropy source implementations
  • Python community for the amazing ecosystem

Made with ❤️ by Fardin Sabid
🇧🇩 From Bangladesh, for the World 🌍


True randomness. No recursion. No state. Just entropy.

After 2 days of discovery, testing, and refinement — the equation is proven.


GitHub stars Follow

If you find this project useful, please ⭐ star it on GitHub!

```

Metadata

Release files for aleam 1.0.3

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

Built distributions (wheels)

Table of built distributions (wheels) for aleam 1.0.3
File Actions
aleam-1.0.3-py3-none-any.whl Python 3 none any Details for aleam-1.0.3-py3-none-any.whl
aleam-1.0.3-cp312-cp312-manylinux2014_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ x86-64 Details for aleam-1.0.3-cp312-cp312-manylinux2014_x86_64.whl
aleam-1.0.3-cp312-cp312-manylinux2014_aarch64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ ARM64 Details for aleam-1.0.3-cp312-cp312-manylinux2014_aarch64.whl
aleam-1.0.3-cp312-cp312-macosx_10_13_universal2.whl CPython 3.12 CPython 3.12 macOS 10.13+ universal2 (ARM64, x86-64) Details for aleam-1.0.3-cp312-cp312-macosx_10_13_universal2.whl

Total release size: 9.6 MB

Release files / aleam-1.0.3-py3-none-any.whl

Download URL aleam-1.0.3-py3-none-any.whl
Size 3.1 MB
Tags Python 3
SHA-256 checksum
How to use checksums
f5b2814355d662b2fb4199141b528b4a92d35458ca35f10008be64b1ae016258
BLAKE2b-256 checksum
How to use checksums
3d5b028e274c26bf8ead380dbeff8c5352c512788d9eb775300a0de8c3cc6761
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.7

Release files / aleam-1.0.3-cp312-cp312-manylinux2014_x86_64.whl

Download URL aleam-1.0.3-cp312-cp312-manylinux2014_x86_64.whl
Size 3.1 MB
Tags CPython 3.12 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
626feeae03dad83b76e406d9f7993fc70bbaa7fde74fd1c7c47af77c8bc93075
BLAKE2b-256 checksum
How to use checksums
baf3f3d562859b4d2db097726d9ce370789bb15d0c405527651e026851b68a3f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.7

Release files / aleam-1.0.3-cp312-cp312-manylinux2014_aarch64.whl

Download URL aleam-1.0.3-cp312-cp312-manylinux2014_aarch64.whl
Size 3.0 MB
Tags CPython 3.12 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
b0804decb968effb0c545ce8e42534da68a4d246b965ba647b3b455e5db67957
BLAKE2b-256 checksum
How to use checksums
1eead705212f32552de2c84e58895b6a36c255617f1702a98f15931856ebc604
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.7

Release files / aleam-1.0.3-cp312-cp312-macosx_10_13_universal2.whl

Download URL aleam-1.0.3-cp312-cp312-macosx_10_13_universal2.whl
Size 423.7 kB
Tags CPython 3.12 macOS 10.13+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
930c4e8907189f159f68684d85fbd151e9c1a2175f6387bbcd38b42cf48a98de
BLAKE2b-256 checksum
How to use checksums
ac4869856c826f1e6f2d0f5f6292c625c5660ded63a6d2f52fe723efd8d17378
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.7

Security for aleam 1.0.3

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

Release history Release notifications | RSS feed

This release

1.0.3 This release

4 release files No provenance

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