Skip to main content

perform probability fusion

Project description

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
  • documentation 😹

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!

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fuz-0.1.2.tar.gz (6.6 MB view details)

Uploaded Source

Built Distribution

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

fuz-0.1.2-py3-none-any.whl (33.5 kB view details)

Uploaded Python 3

File details

Details for the file fuz-0.1.2.tar.gz.

File metadata

  • Download URL: fuz-0.1.2.tar.gz
  • Upload date:
  • Size: 6.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.27.0

File hashes

Hashes for fuz-0.1.2.tar.gz
Algorithm Hash digest
SHA256 b782761c755f4f990daf53fca465dd5eaa5c969163afc96096661ebb565d66a9
MD5 09f1490011af4a6239ea588aa0286e47
BLAKE2b-256 685d3a7a238210c8a6922c7eedf7cf41cd04ba00ec80084a9e75f31132d95af5

See more details on using hashes here.

File details

Details for the file fuz-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: fuz-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 33.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.27.0

File hashes

Hashes for fuz-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3171cf4530f2597a0e7fc85504011dbe36cade057b44142a7cadd8fac51cf2c4
MD5 14180e247f8fd1bfdf7cc6b74db64532
BLAKE2b-256 5081641a510452140579c6b8c74cdf276becd4b6936ae9c2da87f998bf9c9382

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