Skip to main content

Composable tools for quick Monte Carlo modelling and distribution elicitation.

Project description

drisk

Composable tools for quick Monte Carlo modelling, with an emphasis on distribution elicitation and model composition.

drisk provides a compact, notebook-friendly API for probability distributions, elicitation workflows, correlated sampling, decision trees, sensitivity analysis, and composable Monte Carlo models.

drisk is currently in alpha. APIs may change before a stable release.

Links

Installation

Install from PyPI:

pip install drisk

Or with uv:

uv add drisk

drisk requires Python 3.12 or newer.

Quick start

import drisk as dr

# Elicit a distribution from intuitive inputs.
dist = dr.LogitNormal.elicit(lower=0.1, upper=0.25)

# Draw Monte Carlo samples.
samples = dist.sample(1_000)

Features

  • Continuous distributions such as Normal, LogNormal, LogitNormal, Beta, PERT, Gamma, and Exponential
  • Discrete distributions such as Bernoulli, Binomial, Poisson, Geometric, and NegativeBinomial
  • Distribution elicitation, fitting, sampling, plotting, and serialization-friendly parameters
  • Mixture distributions with UvMixture
  • Correlation matrix helpers and Gaussian / Student-t copulas
  • Composable Monte Carlo models via MCModel, MCOperation, and where
  • Decision tree modelling with chance, decision, and outcome nodes
  • One-at-a-time sensitivity analysis helpers

Documentation

The documentation site includes examples and API reference pages:

https://nick-dorsch.github.io/drisk/

Developer setup

This repository uses:

  • mise to install local development tools and run common project tasks
  • uv for Python dependency management and command execution

1. Install tools with mise

Install mise if you do not already have it, then install the tools pinned in .mise.toml:

mise install

This installs the project Python version, uv, ruff, and other helper tools for the repository.

2. Install Python dependencies with uv

Sync the project environment from pyproject.toml and uv.lock:

uv sync --all-groups

Use uv run ... for commands that should execute inside the managed environment:

uv run pytest
uv run ruff check .
uv run python -c "import drisk as dr; print(dr.Normal.elicit(0, 1))"

When adding dependencies, use uv add so pyproject.toml and uv.lock stay in sync:

uv add numpy
uv add --dev pytest
uv add --group docs jupyter

3. Run project tasks with mise

List available tasks:

mise tasks

Common tasks:

mise run test      # run the test suite
mise run lint      # run ruff checks
mise run format    # format the codebase
mise run check     # run lint and tests
mise run docs      # preview the Quarto documentation site

Project layout

src/drisk/
  copulas/                  # copula interfaces and implementations
  correlations/             # correlation matrix helpers
  decision/                 # decision tree nodes, branches, and trees
  distributions/            # distribution interfaces and implementations
  models/                   # composable Monte Carlo model helpers
  sensitivity/              # sensitivity analysis utilities
  arithmetic.py             # arithmetic/composition helpers
  random.py                 # seed/RNG helpers
  summary.py                # summary helpers

tests/                      # pytest suite
docs/                       # Quarto documentation site

License

drisk is distributed under the MIT License. See LICENSE for details.

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

drisk-0.1.1.tar.gz (45.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

drisk-0.1.1-py3-none-any.whl (65.6 kB view details)

Uploaded Python 3

File details

Details for the file drisk-0.1.1.tar.gz.

File metadata

  • Download URL: drisk-0.1.1.tar.gz
  • Upload date:
  • Size: 45.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for drisk-0.1.1.tar.gz
Algorithm Hash digest
SHA256 3ce99dc280058c8fded3b97dadf8224157a666889e94b08c97c841e4e88a6269
MD5 252afbd6f944bf660d4a55fbb04f4aab
BLAKE2b-256 a7a47847576e61aed6fa9e09dd39fb9f31a8415fa473d733374517c3340f2884

See more details on using hashes here.

File details

Details for the file drisk-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: drisk-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 65.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for drisk-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 46d0b956b14abde4bbda6b07cdcbcfe1a32ec7d5e1eb5388d54f9f4c3de94a28
MD5 6c315e2f1f646458253fa6bad3aa4c91
BLAKE2b-256 ec25fd49d954da9bb8ef1181b6600ee99daafb637a51c5ee9aafa2718476b8ca

See more details on using hashes here.

Supported by

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