Skip to main content

PyPI Docs GitHub Open in Colab

blue-sampler / hyperuniform sampler

Generate large stealthy point patterns (i.e. blue noise) on the unit torus $[0, 1)^D$.

Stealthy point patterns exhibit vanishing density fluctuations at low frequencies, making them particularly suited for Monte Carlo integration, image stippling, and any application requiring well-distributed, low-discrepancy points.


📦 Installation

pip install blue-sampler

Quick Start

import blue_sampler as blue

# Generate 10,000 2D blue-noise points
x = blue.sample_points(N=10_000, D=2)
blue.plot(x) 

# Structure factor
blue.plot_structure_factor(x) 

# Image stippling
x = blue.im2points("plots/zebra.jpg")

🖼️ Examples

Uniform sampling (3k points)

Example

Image stippling (20k points)

Example 1


📋 Available Samplers

Main sampling methods

x = blue.sample_points(N, D, method="rgbn") #(N, D)
Method Description
gaussian original Gaussian-Blue-Noise sampler (high quality, slow), A. G. M. Ahmed, J. Ren, and P. Wonka.
rgbn Recursive Gaussian-Blue-Noise (speed-up GBN with robust approximations)
nufft/nufft+ Non-Uniform FFT (speed-up spectral methods with fast fourier transform)
cstit STIT inspired clustering (clusters replace complex polygon geometry)
latjit fast and simple lattice jittering

All presented samplers, having linear complexity in the number of points, are thus intended to scale up to million points (at least in 2/3D) beyond the minute (GPU) or 20 minutes (CPU). The recommanded default is:

  • dimension D = 1/2/3: nufft
  • dimension D = 4/5: rgbn or gaussian (depending on N + gpu availability)
  • dimension 6 or more: gaussian

If sampling runtime is realy a problem, then cstit is recommended (much faster, but not so good blue noise) . QUality can be checked with the structure factor.

Alternative Samplers

Sobol sequence 📏

x = blue.sobol(N, D) #(N, D)

Low-discrepancy quasi-random sequence.

STIT Tessellations (2D only) 🧩

# Raw STIT tessellation (quadrilaterals)
ts = blue.sample_tessels(N) #(N, 4, D=2)
blue.plot_tessels(ts) 

# Convert to point set
x = blue.tessel2points(ts) #(N, m, D=2)

Pinwheel Tilings (2D only) 𖣘

# Base pinwheel triangle
pw0 = blue.pinwheel_base()  #(3, D=2)

# Triangulation level 4
pw4 = blue.pinwheel_transform(pw0, depth=4) #(4*5**depth, 3, D=2)
blue.plot_polygons(pw4) 

#===============================
# Convert Pinwheel to point set:
#===============================
#sample points from the BASE pinwheel
x0 = blue.tessel2points(pw0) #(m, D=2)
#then replicate the sample on the full triangulation,
#in a fractal way
x4 = blue.pinwheel_transform(x0, depth = 4) #(4*5**depth, m, D=2)

Note on GPU support: Most methods can run on CPU only, but they can benefit from GPU acceleration. To install the optional GPU dependencies for a CUDA 12 environment:

pip install blue-sampler[gpu]

If the CUDA 12 installation fails, you may need to install jax, torch, cupy, and cufinufft manually. Once installed, you can check that GPU support is correctly configured by running:

import blue_sampler
blue_sampler.check_gpu()

Note on adaptative sampling: The sampling methods implemented here support adaptive sampling from a target distribution. This feature is still experimental beyond 2d distributions

Note on structure factor: The structure factor (sf) characterizes the density fluctuations of the points in Fourier space and is equivalent to the power spectrum (up to normalization). The estimation of sf assumes that the points domain is the unit hypercube and uses the standard scattering intensity estimator.

Note on cstit: The conversion from geometric objects (polygons, clusters) to point sets is performed by tessel2points resp. cluster2points using a standard moment matching technique developped by L. Lotz and M. A. Klatt (see ref section).


Supported Dimensions

Dimension Status
2–3D Fast
4–5D Supported
≥6D Experimental


References

The algorithms and mathematical tools implemented in blue-sampler are based or inspired from the following works.

  • Gaussian Blue Noise (repulsive interaction kernel)
    A. G. M. Ahmed, J. Ren, and P. Wonka.
    Gaussian Blue Noise.
    ACM Transactions on Graphics (SIGGRAPH Asia), 41(6), 2022.
    DOI: 10.1145/3550454.3555519

  • FReSCo A. Shih, M. Casiulis, and S. Martiniani.
    Fast Generation of Spectrally-Shaped Disorder.
    Physical Review E, 110(3):034122, 2024.
    DOI: 10.1103/PhysRevE.110.034122

  • STIT tessellations and moment matching
    L. Lotz and M. A. Klatt.
    Persistence of asymptotic variance under transport: from hyperfluctuation to stealthy hyperuniformity.
    arXiv:2605.22803, 2026.

  • Aperiodic tiling for hyuperuniformity (here pinwheel)
    A. Gabrielli, B. Jancovici, M. Joyce, J. L. Lebowitz, L. Pietronero, and F. Sylos Labini.
    Generation of Primordial Cosmological Perturbations from Statistical Mechanical Models.
    Physical Review D, 67(4):043506, 2003.

  • SquareNet (v1.3.11). 2026.
    Grid data structure for point clouds, codeveloped with RGBN
    for efficient neighbor query and fourier trnasform in Python.

  • Sobol sequences
    Wrapped from scipy.stats.qmc.Sobol (SciPy).

  • Nufft: The non uniform fast fourier transform (nufft) is performed using the finufft / cufinufft library [FIN] A parallel non-uniform fast Fourier transform library based on an “exponential of semicircle”
    kernel. A. H. Barnett, J. F. Magland, and L. af Klinteberg. SIAM J. Sci. Comput. 41(5), C479-C504 (2019).


Positioning and scope

One can find extensive Blue-noise and hyperuniform sampling methods in the literature, all involving different trade-offs between spectral quality, computational cost, dimensionality, hardware requirements, implementation complexity, and support for adaptive sampling. To briefly cite some of them: Perturbed lattices are simple and fast; Poisson-disk is a mature and popular tool; Void-and-Cluster masks offer instant execution but are restricted to regular grids; Relaxation methods (such as Lloyd or CCVT) are classic but slow to converge and prone to structural artifacts; Optimal Transport (BNOT) provides natural adaptive sampling but is computationally heavy; Gaussian blue noise (GBN) achieves ultra-high spatial quality but has quadratic complexity; and Fast reciprocal space Correlator (FReSCo) combines ultra-high quality with near-linear complexity, though it requires installing heavy external dependencies or familiarity with docker containers.

blue-sampler is not intended as a universal replacement for these methods. It is a lightweight Python framework for experiments on blue noise and hyperuniformity, targeting simple installation (native Python code, jax powered) and device flexibility (CPU/GPU), high spectral quality (achieving the commonly accepted "stealthy" criterions $S(k) \lesssim 10^{-3} - 10^{-4}$), adaptive sampling, and support for 3D and higher dimensions.


License

MIT

Metadata

Release files for blue-sampler 2.1.8

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

Source distribution (sdist)

Source distribution for blue-sampler 2.1.8
File Size Uploaded
blue_sampler-2.1.8.tar.gz 51.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for blue-sampler 2.1.8
File Interpreter ABI Platform
blue_sampler-2.1.8-py3-none-any.whl Python 3 none any Details

Total release size: 114.0 kB

Release files / blue_sampler-2.1.8.tar.gz

Download URL blue_sampler-2.1.8.tar.gz
Size 51.2 kB
Tags Source
SHA-256 checksum
How to use checksums
37d513f07b184dc2fb723b25a0099987704282949d17c6da7449dd3407096057
BLAKE2b-256 checksum
How to use checksums
4c3f87d74103fdde24111879561488c683df0542fcb287b5f751c756ed2e14a2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Release files / blue_sampler-2.1.8-py3-none-any.whl

Download URL blue_sampler-2.1.8-py3-none-any.whl
Size 62.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
69c8ead39d72be64f9cb475c4f87e7f3d53bb6ef6ae7313bd46ae328728aa9f8
BLAKE2b-256 checksum
How to use checksums
9e5a2ebd25f75530b2aa14ded397a5eb086f952ddc591a13a88fe4d9271285f5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Release history Release notifications | RSS feed

3.1.3

2 release files

3.1.2

2 release files

3.1.1

2 release files

3.1.0

2 release files

3.0.5

2 release files

3.0.4

2 release files

3.0.3

2 release files

3.0.2

2 release files

3.0.1

2 release files

3.0.0

2 release files

This release

2.1.8 This release

2 release files

2.1.7

2 release files

2.1.6

2 release files

2.1.5

2 release files

2.1.4

2 release files

2.1.3

2 release files

2.1.2

2 release files

2.1.1

2 release files

2.1.0

2 release files

2.0.0

2 release files

1.3.15

2 release files

1.3.14

2 release files

1.3.13

2 release files

1.3.12

2 release files

1.3.11

2 release files

1.3.10

2 release files

1.3.9

2 release files

1.3.8

2 release files

1.3.7

2 release files

1.3.6

2 release files

1.3.5

2 release files

1.3.4

2 release files

1.3.3

2 release files

1.3.2

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.7

2 release files

1.2.6

2 release files

1.2.5

2 release files

1.2.4

2 release files

1.2.3

2 release files

1.2.2

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.1.18

2 release files

0.1.17

2 release files

0.1.16

2 release files

0.1.15

2 release files

0.1.14

2 release files

0.1.13

2 release files

0.1.12

2 release files

0.1.11

2 release files

0.1.10

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

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