Metadata-Version: 2.3
Name: fuz
Version: 0.1.3
Summary: perform probability fusion
Project-URL: changelog, https://github.com/viamiraia/fuz/blob/master/changelog.md
Project-URL: documentation, https://code.raia.fun/fuz
Project-URL: homepage, https://code.raia.fun/fuz
Project-URL: issues, https://github.com/viamiraia/fuz/issues
Project-URL: source, https://github.com/viamiraia/fuz
Project-URL: source_archive, https://github.com/viamiraia/fuz/archive/8a819679df964caf0b97aaeb4a77a03418ec28e1.zip
Author-email: "miraia s. chiou" <viamiraia@gmail.com>
License: BSD 3-Clause License
        
        Copyright (c) 2024, Miraia S. Chiou
        
        Redistribution and use in source and binary forms, with or without
        modification, are permitted provided that the following conditions are met:
        
        1. Redistributions of source code must retain the above copyright notice, this
           list of conditions and the following disclaimer.
        
        2. Redistributions in binary form must reproduce the above copyright notice,
           this list of conditions and the following disclaimer in the documentation
           and/or other materials provided with the distribution.
        
        3. Neither the name of the copyright holder nor the names of its
           contributors may be used to endorse or promote products derived from
           this software without specific prior written permission.
        
        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
        AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
        DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
        FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
        SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
        CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
        OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
        OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Environment :: GPU
Classifier: Environment :: GPU :: NVIDIA CUDA
Classifier: Environment :: GPU :: NVIDIA CUDA :: 12
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Education
Classifier: Intended Audience :: Information Technology
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Scientific/Engineering :: Information Analysis
Classifier: Topic :: Scientific/Engineering :: Mathematics
Classifier: Topic :: Software Development
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Utilities
Requires-Python: >=3.10
Requires-Dist: attrs
Requires-Dist: jaxtyping
Requires-Dist: narwhals
Requires-Dist: plum-dispatch
Requires-Dist: scipy
Provides-Extra: demo
Requires-Dist: altair; extra == 'demo'
Requires-Dist: marimo; extra == 'demo'
Requires-Dist: matplotlib; extra == 'demo'
Requires-Dist: mpltern; extra == 'demo'
Requires-Dist: pandas; extra == 'demo'
Requires-Dist: polars; extra == 'demo'
Description-Content-Type: text/markdown


<h1 align='center'>fuz</h1>

**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:

- ch1. [bernoulli to beta](https://code.raia.fun/fuz/mo/obr1/index.html)
- ch2. [to infinity](https://code.raia.fun/fuz/mo/obr2/index.html)

## quickstart

`pip install fuz`

### distributions

```python
import fuz.dists as fd
a = fd.Beta(5,4)
a.stats
```

```python
b = fd.beta_from_mode_trials(0.9,10)
d = fd.Dirichlet([3,6,2])
```

### logarithmic manipulation

```python
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

```python
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!