A Python package for measure-theoretic probability theory.
Project description
SigAlg
A Python package for finite, measure-theoretic probability theory and stochastic processes. The library emphasizes mathematical fidelity while remaining practical for simulations and numerical experiments.
This package is under active development. Extensive documentation is coming soon.
Installation
pip install sigalg
Quick Examples
Build and simulate a random walk:
import matplotlib.pyplot as plt
from sigalg.core import Time
from sigalg.processes import RandomWalk
# Create a random walk with 100 discrete time steps
T = Time.discrete(length=100)
X = RandomWalk(p=0.7, time=T)
# Simulate 10 trajectories
X.from_simulation(n_trajectories=10, random_state=42)
# Plot trajectories
_, ax = plt.subplots(figsize=(7, 4))
X.plot_trajectories(ax=ax)
plt.show()
Compute conditional expectation of a random variable with respect to a $\sigma$-algebra:
from sigalg.core import (
Operators,
ProbabilityMeasure,
RandomVariable,
SampleSpace,
SigmaAlgebra,
)
# Create a sample space with 4 outcomes, labeled 0, 1, 2, 3
Omega = SampleSpace().from_sequence(size=4)
# Define a probability measure by assigning probabilities to each outcome
P = ProbabilityMeasure(sample_space=Omega).from_dict(
{
0: 0.2, # P(0) = 0.2
1: 0.3, # P(1) = 0.3
2: 0.3, # P(2) = 0.3
3: 0.2, # P(3) = 0.2
}
)
# Define a random variable by assigning values to each outcome
X = RandomVariable(domain=Omega, name="X").from_dict(
{
0: 1, # X(0) = 1
1: 2, # X(1) = 2
2: 8, # X(2) = 8
3: 3, # X(3) = 3
}
)
# Sigma-algebras are defined by partitioning the sample space into sets called atoms
F = SigmaAlgebra(sample_space=Omega, name="F").from_dict(
{
0: "A", # outcome 0 is in atom A
1: "A", # outcome 1 is in atom A
2: "B", # outcome 2 is in atom B
3: "B", # outcome 3 is in atom B
}
)
# Compute conditional expectation E(X|F)
E_X_F = Operators.expectation(rv=X, sigma_algebra=F, probability_measure=P)
print(E_X_F)
Random vector 'E(X|F)':
E(X|F)
sample
0 1.6
1 1.6
2 6.0
3 6.0
Author
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 sigalg-0.1.1.tar.gz.
File metadata
- Download URL: sigalg-0.1.1.tar.gz
- Upload date:
- Size: 80.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
af3b45438fe2513646b068bb3c37637c936594717bc635a19177d36fb2224d8e
|
|
| MD5 |
53589a520f506dd76997a8acb13590da
|
|
| BLAKE2b-256 |
89ef71619c6ce738ff197a5d49e26ff213d7415fdd09a6db971ab43874a05599
|
File details
Details for the file sigalg-0.1.1-py3-none-any.whl.
File metadata
- Download URL: sigalg-0.1.1-py3-none-any.whl
- Upload date:
- Size: 100.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3b002ed3565ee9b3ae5beac6c9a59cd053bb14a46f1218bd90dbedfe647d180d
|
|
| MD5 |
4dc5430716e29516f059a055324728ab
|
|
| BLAKE2b-256 |
0d4284cf55f8c1ca4efbea565deab0fd31a47035efe7bab7d3e12bd690d1a4c8
|