Skip to main content

High Performance Statistics Library

Project description

Stamox

Stamox: A Thin Wrapper of JAX and Equinox for Statistics

Just out of curiosity of Fucntional Programming, I wrote this package. It is a thin wrapper of JAX and Equinox for statistics. It is not a complete package, and in heavy development.

Inspired by many packages from Python and R, I hope to fuse different features of them into one package, like %>% in dplyr, or apis from statsmodels and scipy etc.

Installation

pip install stamox

Documentation

Not yet.

Quick Start

Similar but faster distribution functions to R

from stamox.distribution import *
import jax.random as jrandom

key = jrandom.PRNGKey(20010813)

# random
x = rnorm(key, sample_shape=(1000, ))
# cdf
pnorm(x)
# ppf
qnorm(x)
# pdf
dnorm(x)

Fearless Pipeable

>> is the pipe operator, which is the similar to |> in F# and Elixir or %>% in R. But >> focus on the composition of functions not the data. You must call pipeable functions with ().

  • Internal Functions Pipeable
from stamox.distribution import *
import jax.random as jrandom

key = jrandom.PRNGKey(20010813)

# random and ppf
pipe = rnorm(sample_shape=(1000, )) >> qnorm
print(pipe())
  • Custom Functions Pipeable
from stamox.core import make_pipe, make_partial_pipe, Pipeable
import jax.numpy as jnp
import jax.random as jrandom

x = jnp.ones((1000, ))
# single input, simply add make pipe
@make_pipe
def f(x):
    return x ** 2

# multiple input, add make partial pipe
@make_partial_pipe
def g(x, y):
    return x + y

# Notice Only One Positional Argument Can Be Received Along the pipe
h = Pipeable(x) >> f >> g(y=2.) >> f >> g(y=3.) >> f
print(h())
  • Compatible With JAX and Equinox
from stamox.core import make_pipe, make_partial_pipe, Pipeable
import jax.numpy as jnp
import equinox as eqx

@make_partial_pipe
@filter_jit
@filter_vmap
@filter_grad
def f(x, y):
    return y * x ** 3
       
print(f(y=3.)(jnp.array([1., 2., 3.])))

See More

JAX Equinox

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

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

stamox-0.0.1-py3-none-any.whl (51.3 kB view details)

Uploaded Python 3

File details

Details for the file stamox-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: stamox-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 51.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.0

File hashes

Hashes for stamox-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5f8e803583946da9f43fe6477bb4de8538787165031c49737dbde89282d67785
MD5 318c71605f6b1a38a1944f93acda79dd
BLAKE2b-256 2145f49420114d9980aa3a8bd5daa747770c3ef3b8c7ac2e6ef25eb12db25a0b

See more details on using hashes here.

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