Python library for Localized Distribution (LCD)-based Gaussian sampling.
Project description
Deterministic Gaussian Sampling
Deterministic approximation and reduction of multivariate Dirac mixtures and Gaussian distributions using an optimized C++ backend with a clean Python interface.
The computational core is written in C++ for high performance.
The Python package provides a NumPy-friendly API and ships with precompiled binaries.
📖 Full API Documentation:
https://kit-isas.github.io/deterministic_gaussian_sampling_py/
Installation
pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ deterministic-gaussian-sampling
Requirements
- Python ≥ 3.8
- NumPy
Optional (for visualization examples):
- SciPy
- Matplotlib
Overview
The package provides two main classes:
DiracToDiracApproximation
GaussianToDiracApproximation
They allow you to:
- Reduce large discrete sample sets to fewer deterministic points
- Approximate Gaussian distributions with optimized Dirac support points
- Compute the modified van Mises distance
- Compute the analytic gradient of the distance
1️⃣ Dirac-to-Dirac Reduction
Reduce M discrete samples in ℝᴺ to L < M optimized deterministic samples.
Basic Example
import deterministic_gaussian_sampling
import numpy as np
# Generate example data
num_points = 3000
N = 2
L = 12
x = np.random.normal(0, 1, num_points)
y = np.random.normal(0, 1, num_points)
original_points = np.column_stack((x, y))
# Create approximation object
d2d = deterministic_gaussian_sampling.DiracToDiracApproximation()
# Allocate output array (L x N)
reduced = np.empty((L, N))
# Run reduction (multi-threaded version)
result = d2d.approximate_thread_double(
original_points, # input samples (M x N)
num_points, # M
L, # number of target points
N, # dimension
reduced # output buffer
)
print("Success:", result.result)
print("Reduced points:\n", reduced)
del d2d
Available Methods
approximate_double(...) # single-threaded
approximate_thread_double(...) # multi-threaded
approximate_function_double(...) # custom weight functions
2️⃣ Gaussian-to-Dirac Approximation
Approximate a multivariate Gaussian distribution with L deterministic Dirac points.
Standard Normal Example
import deterministic_gaussian_sampling
import numpy as np
N = 2
L = 12
g2d = deterministic_gaussian_sampling.GaussianToDiracApproximation()
approx = np.empty((L, N))
result = g2d.approximate_snd_double(
L,
N,
approx
)
print("Success:", result.result)
print("Dirac points:\n", approx)
del g2d
Full Covariance Example
import numpy as np
import deterministic_gaussian_sampling
Sigma = np.array([[2.0, 0.5],
[0.5, 2.0]])
N = 2
L = 12
g2d = deterministic_gaussian_sampling.GaussianToDiracApproximation()
approx = np.empty((L, N))
result = g2d.approximate_double(
Sigma, # covariance matrix
L,
N,
approx
)
print("Success:", result.result)
print("Dirac points:\n", approx)
del g2d
The covariance matrix is internally diagonalized and the optimized points are automatically transformed back into the original coordinate system.
Distance and Gradient
You can evaluate approximation quality directly.
Compute Distance
distance = d2d.approximate_double.modified_van_mises_distance_sq(
y, M, L, N, x
)
Compute Analytic Gradient
gradient = d2d.approximate_double.modified_van_mises_distance_sq_derivative(
y, M, L, N, x
)
This allows integration into:
- Custom optimization routines
- Gradient-based machine learning workflows
- Differentiable programming setups
Custom Weight Functions (Advanced)
You can define position-dependent weights:
def wX(x):
return np.exp(-np.sum(x**2))
def wXD(x):
return -2 * x * np.exp(-np.sum(x**2))
Use them with:
d2d.approximate_function_double(
y, M, L, N, x,
wX=wX,
wXD=wXD
)
Notes
- All heavy computations run in optimized C++
- Python layer is lightweight and NumPy-based
- Precompiled binaries are included in the package
- Works on Linux and Windows
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file deterministic_gaussian_sampling-0.0.1.tar.gz.
File metadata
- Download URL: deterministic_gaussian_sampling-0.0.1.tar.gz
- Upload date:
- Size: 2.0 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2ad743a61497cb84ff2514cc7881759955e0c1ede18662d3e156660e182c60b7
|
|
| MD5 |
4d19fdbbcde3eba310015e92620c5fd6
|
|
| BLAKE2b-256 |
de87b319821ed988ccf8b5d5e31b751287d6a38bb9469c4009bea02f8ca0a123
|
Provenance
The following attestation bundles were made for deterministic_gaussian_sampling-0.0.1.tar.gz:
Publisher:
build-package.yml on KIT-ISAS/deterministic_gaussian_sampling_py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
deterministic_gaussian_sampling-0.0.1.tar.gz -
Subject digest:
2ad743a61497cb84ff2514cc7881759955e0c1ede18662d3e156660e182c60b7 - Sigstore transparency entry: 974736375
- Sigstore integration time:
-
Permalink:
KIT-ISAS/deterministic_gaussian_sampling_py@e3cbc816706c8ec26de45186e2decf924893f6ce -
Branch / Tag:
refs/heads/main - Owner: https://github.com/KIT-ISAS
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build-package.yml@e3cbc816706c8ec26de45186e2decf924893f6ce -
Trigger Event:
push
-
Statement type:
File details
Details for the file deterministic_gaussian_sampling-0.0.1-py3-none-any.whl.
File metadata
- Download URL: deterministic_gaussian_sampling-0.0.1-py3-none-any.whl
- Upload date:
- Size: 2.0 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6fc3f0d1f75891a79d25bc5b4e0fadc041d2dc8d8fd6135a0e5480f3afd28209
|
|
| MD5 |
4993a1c215edb8d5e865a6521c4c64a7
|
|
| BLAKE2b-256 |
b0ed50fc3b72d3d3b131d30734fce5096d747d18b194df221a91ce1d20db86b1
|
Provenance
The following attestation bundles were made for deterministic_gaussian_sampling-0.0.1-py3-none-any.whl:
Publisher:
build-package.yml on KIT-ISAS/deterministic_gaussian_sampling_py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
deterministic_gaussian_sampling-0.0.1-py3-none-any.whl -
Subject digest:
6fc3f0d1f75891a79d25bc5b4e0fadc041d2dc8d8fd6135a0e5480f3afd28209 - Sigstore transparency entry: 974736403
- Sigstore integration time:
-
Permalink:
KIT-ISAS/deterministic_gaussian_sampling_py@e3cbc816706c8ec26de45186e2decf924893f6ce -
Branch / Tag:
refs/heads/main - Owner: https://github.com/KIT-ISAS
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build-package.yml@e3cbc816706c8ec26de45186e2decf924893f6ce -
Trigger Event:
push
-
Statement type: