{"id":10061,"library":"preliz","title":"Preliz Library","description":"Preliz is a Python library for exploring and eliciting probability distributions. It provides a flexible and object-oriented framework for defining, manipulating, and visualizing various distributions, commonly used for setting priors in Bayesian inference workflows. The current version is 0.24.0, and it maintains an active development and release cadence.","status":"active","version":"0.24.0","language":"en","source_language":"en","source_url":"https://github.com/eliciting-distributions/preliz","tags":["statistics","probability","distributions","bayesian-inference","prior-elicitation"],"install":[{"cmd":"pip install preliz","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"note":"As of v0.20.0, distributions are directly available from the top-level 'preliz' module. The old path was deprecated.","wrong":"from preliz.distributions import Normal","symbol":"Normal","correct":"from preliz import Normal"},{"note":"General import for accessing the library's features.","symbol":"preliz","correct":"import preliz"}],"quickstart":{"code":"import preliz\nimport numpy as np\n\n# Define a Normal distribution\nnorm_dist = preliz.Normal(mu=0, sigma=1)\n\n# Get PDF at a specific point\nprint(f\"PDF at x=0: {norm_dist.pdf(0):.3f}\")\n\n# Sample from the distribution\nsamples = norm_dist.rvs(size=100)\nprint(f\"Mean of 100 samples: {np.mean(samples):.2f}\")\nprint(f\"Std dev of 100 samples: {np.std(samples):.2f}\")\n\n# Access a scipy.stats compatible object (if needed)\nscipy_norm = norm_dist.to_scipy()\nprint(f\"Scipy PDF at x=0: {scipy_norm.pdf(0):.3f}\")","lang":"python","description":"Demonstrates how to define a distribution, calculate its PDF, sample from it, and convert it to a scipy.stats compatible object."},"warnings":[{"fix":"Update your import statements. For example, change `from preliz.distributions import Normal` to `from preliz import Normal`. A backward-compatible `from preliz import distributions` was added in `0.22.0`, but direct import is preferred.","message":"Direct import paths for individual distributions changed in `0.20.0`. Previously, distributions like `Normal` were imported from `preliz.distributions`. Now, they are directly available from the top-level `preliz` module.","severity":"breaking","affected_versions":">=0.20.0"},{"fix":"Use the `to_scipy()` method available on `preliz` distribution objects to obtain a `scipy.stats` compatible distribution, or directly use the `preliz` object's native methods for calculations and sampling.","message":"Preliz distribution objects are not direct subclasses of `scipy.stats` distributions and cannot be used interchangeably with `scipy.stats` functions without explicit conversion. They offer their own `pdf()`, `cdf()`, `rvs()` methods.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Replace calls to `dist.plot_pdf()` or `dist.plot_cdf()` with `dist.plot()`. You can specify the desired plot type using the `plot_type` argument, e.g., `dist.plot(plot_type='pdf')`.","message":"The plotting methods `plot_pdf()` and `plot_cdf()` on distribution objects have been deprecated in favor of a more unified `plot()` method.","severity":"deprecated","affected_versions":"Likely >=0.22.0 (check specific changelog)"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Update your import statements to directly import distributions from the top-level `preliz` module, e.g., `from preliz import DistName`.","cause":"Attempting to access a distribution via `preliz.distributions.DistName` after version `0.20.0`, when the `distributions` submodule was removed from direct access.","error":"AttributeError: module 'preliz' has no attribute 'distributions'"},{"fix":"Ensure you are using the correct methods (`.pdf()`, `.cdf()`, `.rvs()`) or converting the `preliz` object to a `scipy.stats` object using `.to_scipy()` before passing it to external functions.","cause":"This or similar `TypeError` can occur when a `preliz` distribution object is passed to a function expecting a numerical value or a `scipy.stats` distribution, without proper conversion.","error":"TypeError: 'Normal' object cannot be interpreted as an integer"},{"fix":"Change the import statement to `from preliz import Normal` to import the distribution directly from the top-level `preliz` package.","cause":"This error specifically indicates that an older import statement `from preliz.distributions import Normal` is being used with `preliz` versions `0.20.0` or later, where this import path is no longer valid.","error":"ImportError: cannot import name 'Normal' from 'preliz.distributions' (...path/to/preliz/distributions.py)"}]}