JAX based lib for sampling statistical distributions.
Project description
JAXampler
JAX based lib for sampling statistical distributions.
Samplers
In order to sample from a distribution, import the corresponding sampler from the jaxampler.sampler
module and call the sample
method with the required arguments.
from jaxampler.rvs import Beta, Normal
from jaxampler.sampler import AcceptRejectSampler
scale = 1.35
N = 100_000
target_rv = Normal(mu=0.5, sigma=0.2)
proposal_rv = Beta(alpha=2, beta=2)
ar_sampler = AcceptRejectSampler()
samples = ar_sampler.sample(
target_rv=target_rv,
proposal_rv=proposal_rv,
scale=scale,
N=N,
)
JAXampler currently supports the following samplers:
- Inverse Transform Sampling
- Accept-Rejection Sampling
- Adaptive Accept-Rejection Sampling
- Metropolis-Hastings
- Hamiltonian Monte Carlo
- Slice Sampling
- Gibbs Sampling
- Importance Sampling
Random Variables
To create a new random variable, import the corresponding type from the jaxampler.rvs
i.e. DiscreteRV
and ContinuousRV
for discrete and continuous random variables respectively. Then, instantiate the random variable with the required parameters and implement the necessary methods (logpdf, cdf, and ppf etc). JAXampler currently supports the following random variables:
Discrete Random Variables
Continuous Random Variables
- Beta
- Boltzmann
- Cauchy
- Chi Square
- Exponential
- Gamma
- Gumbel
- Laplace
- Log Normal
- Logistic
- Multivariate Normal
- Normal
- Pareto
- Rayleigh
- Student t
- Triangular
- Truncated Normal
- Truncated Power Law
- Uniform
- Weibull
Citing Jaxampler
To cite this repository:
@software{jaxampler2023github,
author = {Meesum Qazalbash},
title = {{JAXampler}: tool for sampling statistical distributions},
url = {http://github.com/Qazalbash/jaxampler},
version = {0.0.1},
year = {2023}
}
Contributors
Made with contrib.rocks.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
File details
Details for the file jaxampler-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: jaxampler-0.0.2-py3-none-any.whl
- Upload date:
- Size: 41.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d17aa422380b5cdf2fe612479397427c6ce430b976b45562defd58a852a2b1fc |
|
MD5 | 1deab411b0ce2b90ef47c2796b628033 |
|
BLAKE2b-256 | 932c9b22019f9045b6dcbf36b381e763fe207518546f59ea4f7603b041a5291e |