Skip to main content

Python client for the MakeDistribution API (docs).

Offers a thin wrapper around the API (JSONClient) as well as the Distribution class which lets you interact with MakeDistribution.com distributions as if they were ordinary SciPy distribution objects.

At the moment, Distribution supports commonly used functionality which should be sufficient for the great majority of use cases. Eventually, the goal is to provide a full drop-in replacement for SciPy's distributions (specifically, rv_continuous_frozen).

Installation

pip install make_distribution  # or `poetry add make_distribution`

Usage

import os

import make_distribution.client

TOKEN = os.environ["MAKEDISTRIBUTION_API_TOKEN"]

json_client = make_distribution.client.JSONClient(token=TOKEN)

client = make_distribution.client.SciPyClient(json_client)

data = {
    # See API docs for available families
    "family": {"requested": "cinterp5_01"},
    "arguments": {
        "quantiles": [
            {
                "p": 0.1,
                "x": 0,
            },
            {
                "p": 0.5,
                "x": 1,
            },
            {
                "p": 0.9,
                "x": 4,
            },
        ]
    },
}

# `dist` is an instance of class `Distribution`
dist = client.post("1d/dists/", json=data)

# Print basic information about the distribution
print(dist)

# `dist` lets you query other endpoints with a SciPy-like interface
size = 5
print(f"rvs(size={size}) = {dist.rvs(size)}")  # Draw random samples

x = [1, 2, 3]
print(f"cdf({x}) = {dist.cdf(x)}") # Cumulative distribution function
print(f"pdf({x}) = {dist.pdf(x)}") # Probability density function

p = [0.1, 0.2, 0.3]
print(f"ppf({p}) = {dist.ppf(p)}") # Quantile function (inverse CDF)

Release files for make_distribution 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for make_distribution 0.2.0
File Size Uploaded
make_distribution-0.2.0.tar.gz 3.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for make_distribution 0.2.0
File Interpreter ABI Platform
make_distribution-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 8.7 kB

Release files / make_distribution-0.2.0.tar.gz

Download URL make_distribution-0.2.0.tar.gz
Size 3.9 kB
Tags Source
SHA-256 checksum
How to use checksums
1a08219c1d61aa5b78da5ccf468f58b51e7fc2ab93cf35cd7cef020b405f4142
BLAKE2b-256 checksum
How to use checksums
94f7a02ea9b8f1ea496e07a0ab384b600eb508a0e5de5cd07ee39519e22e1cbd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.2 CPython/3.12.2 Darwin/23.5.0

Release files / make_distribution-0.2.0-py3-none-any.whl

Download URL make_distribution-0.2.0-py3-none-any.whl
Size 4.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d1b1d26eee80c8cb1ef4ec7d26dd6e1a424910c8abc374b369e743c2872ad0dd
BLAKE2b-256 checksum
How to use checksums
815bac72a63dceaf3e9bd04a99df0d946c00e277b4a634f57baae413b448ab88
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.2 CPython/3.12.2 Darwin/23.5.0

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page