Metadata-Version: 2.2
Name: density
Version: 1.0.1
Summary: Specifications of parametric density functions
Home-page: https://github.com/microprediction/density
Author: microprediction
Author-email: peter.cotton@microprediction.com
License: MIT
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pydantic
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: license
Dynamic: requires-dist
Dynamic: summary

# Density ![tests_312](https://github.com/microprediction/density/workflows/tests_312/badge.svg)
A simple `dict` specification of an algebra of continuous univariate density function mixtures using `pydantic`. 

## Install

   pip install density 
   
## Specifying densities or mixtures of the same
See [examples](https://github.com/microprediction/density/tree/main/examples) of specifying densities. 

See the [Scipy manifest](https://github.com/microprediction/density/blob/main/density/schemachecker/scipydensitymanifest.py) for a list of densities. 



## Evaluating densities 
The current use case involves evaluation of a single data point at a time. For this we recommend using the `builtin` option rather than `scipy`, and using [https://github.com/microprediction/densitypdf](https://github.com/microprediction/densitypdf) package. 


      from densitypdf import density_pdf
      
      mixture_spec = {
          "type": "mixture",
          "components": [
              {
                  "density": {
                      "type": "scipy",
                      "name": "norm",
                      "params": {"loc": 0, "scale": 1}
                  },
                  "weight": 0.6
              },
              {
                  "density": {
                      "type": "builtin",
                      "name": "norm",
                      "params": {"loc": 2.0, "scale": 1.0}
                  },
                  "weight": 0.4
              }
          ]
      }
      
      val = density_pdf(mixture_spec, x=0.0)


You can also evaluate manually of course, per examples [here](https://github.com/microprediction/density/tree/main/examples/evaluation). 
