Skip to main content

fuz

fuz is a library for probability fusion, allowing the merging of distribution functions in a principled manner.

with fuz, you can do things like bayesian evidence updating, optimal bayesian ranking, and fuzzy logic.

highlights

  • pooling
    • linear, multiplicative, geometric, holder ...etc.
  • fuzzy logic extension to distribution functions
  • numerical integration in logarithmic space for stability
  • NaN and logarithmic complex number handling
  • distribution tools

upcoming features

  • wider compatibility with narwhals
    • dataframes, functions, samples ...etc.
  • initial gpu support with jax
  • more documentation 😹

demos

check out the marimo demos at:

quickstart

pip install fuz

distributions

import fuz.dists as fd
a = fd.Beta(5,4)
a.stats
b = fd.beta_from_mode_trials(0.9,10)
d = fd.Dirichlet([3,6,2])

logarithmic manipulation

import numpy as np
from fuz.log import complex_lsub, lsimp_irreg

a = np.log([[1,np.nan],[3,4]])
b = np.log([[3,2],[6,1]])
print(complex_lsub(a,b))

x = np.linspace(0,1,1025)
b = fd.beta_from_mu_k(0.3,9)
c = fd.beta_from_mode_k(0.3,9)
y = b.logpdf(x) * c.logcdf(x)
np.exp(lsimp_irreg(y,x))

note - integrating y here gives you the win rate of b over c. see the demo folder for more.

fuzzy logic

import fuz.logic as fzl

x = np.linspace(0,1,1025)
b = fd.beta_from_mode_var(0.7,0.01)
c = fd.beta_from_mu_var(0.7,0.01)
b_negpdf = fzl.negf(b.pdf)
negb_and_c = fzl.ands(x, b_negpdf(x), c.pdf(x))

pooling

ranking

more

see demo folder (pip install marimo first) for more usage.

other

the official pronunciation of fuz is a fugued function of fuzzy fusion 😉

abstract

fuz is a python library for fusion of probability distributions, bayesian evidence updating and ranking, fuzzy logic, operations in logarithmic space, and more. fuz includes several original contributions, including a performant bayesian averaging/ranking algorithm that is mathematically optimal, equations for determining whether one pdf "wins" over another, and multiple demonstrations of equivalence. these include the equivalence of simple kalman filtering, bayesian updating, and multiplicative (upco) pooling, the equivalence of mode-parameterization of beta and dirichlet distributions to optimal bayesian averaging, useful limits as the dirichlet $\alpha_0$ approaches infinity, and various equivalences for discrete distributions.

acknowledgements

thanks to jane liou for her useful insights and support!

Release files for fuz 0.1.3

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

Source distribution (sdist)

Source distribution for fuz 0.1.3
File Size Uploaded
fuz-0.1.3.tar.gz 149.0 kB Details

Built distribution (wheel)

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

Total release size: 185.7 kB

Release files / fuz-0.1.3.tar.gz

Download URL fuz-0.1.3.tar.gz
Size 149.0 kB
Tags Source
SHA-256 checksum
How to use checksums
e38fa66c7d2220e54a9f712a27fcb3eb75e41029bb70714d06a8a5a3d89cb878
BLAKE2b-256 checksum
How to use checksums
7bc60998ef0216c587eadbe2686529b86982bc4c908633b05ed23a4af3cb0654
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.27.0

Release files / fuz-0.1.3-py3-none-any.whl

Download URL fuz-0.1.3-py3-none-any.whl
Size 36.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e3127fb5115160ca42f40e36897e472902bbb91c8299093a8e642cfee2c404ea
BLAKE2b-256 checksum
How to use checksums
7e6c575de5cd95cb414426ab43b6553bb4e115d2b5681e74bcbaaa838e7f345f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.27.0

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

0.1.2

2 release files

0.1.1

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