Skip to main content

JAX based lib for sampling statistical distributions.

Project description

JAXampler

Python package Upload Python Package

JAX based lib for sampling statistical distributions.

Install

pip install jaxampler

Samplers

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:

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

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.3},
    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 Distribution

jaxampler-0.0.3.tar.gz (16.3 kB view hashes)

Uploaded Source

Built Distribution

jaxampler-0.0.3-py3-none-any.whl (41.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page