# Bayesian Optimal Experiment Design
[![PyPI package](https://img.shields.io/badge/pip%20install-bayesdesign-brightgreen)](https://pypi.org/project/bayesdesign/) [![GitHub Release](https://img.shields.io/github/v/release/dkirkby/bayesdesign?color=green)](https://github.com/dkirkby/bayesdesign/releases) [![Actions Status](https://github.com/dkirkby/bayesdesign/workflows/Test/badge.svg)](https://github.com/dkirkby/bayesdesign/actions) [![License](https://img.shields.io/github/license/dkirkby/bayesdesign)](https://github.com/dkirkby/bayesdesign/blob/main/LICENSE)
Use this package to calculate expected information gain for Bayesian optimal experiment design. For an introduction to this topic, see this [interactive notebook](https://observablehq.com/@dkirkby/boed). To perform a similar calculation with this package, use:
```python
from bed.grid import Grid, GridStack
from bed.design import ExperimentDesigner
designs = Grid(t_obs=np.linspace(0, 5, 51))
features = Grid(y_obs=np.linspace(-1.25, 1.25, 100))
params = Grid(amplitude=1, frequency=np.linspace(0.2, 2.0, 181), offset=0)
sigma_y=0.1
with GridStack(features, designs, params):
y_mean = params.amplitude * np.sin(params.frequency * (designs.t_obs - params.offset))
y_diff = features.y_obs - y_mean
likelihood = np.exp(-0.5 * (y_diff / sigma_y) ** 2)
features.normalize(likelihood)
designer = ExperimentDesigner(params, features, designs, likelihood)
prior = np.ones(params.shape)
params.normalize(prior);
designer.calculateEIG(prior)
plt.plot(designs.t_obs, designer.EIG)
```
Browse the [examples folder](https://github.com/dkirkby/bayesdesign/) to learn more about using this package.
To run the examples in [google colab](https://colab.research.google.com/), select **GitHub** and enter `https://github.com/dkirkby/bayesdesign`.
## Installation
Install the [latest released version](https://github.com/dkirkby/bayesdesign/releases/latest) from [pypi](https://pypi.org/project/bayesdesign/) using:
```
pip install bayesdesign
```
The only required dependency is numpy. The optional plot module also requires matplotlib.
The changes with each version are documented [here](CHANGELOG.md).
## Upgrade
To upgrade your pip-installed package to the [latest released version](https://github.com/dkirkby/bayesdesign/releases/latest) use:
```
pip install bayesdesign --upgrade
```
## Contributing
If you have feedback or would like to contribute to this package, please see our [contributor's guide](CONTRIBUTING.md).
Raw data
{
"_id": null,
"home_page": "https://github.com/dkirkby/bayesdesign",
"name": "bayesdesign",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": "bayes, optimization",
"author": "David Kirkby",
"author_email": "dkirkby@uci.edu",
"download_url": "https://files.pythonhosted.org/packages/0c/b4/96c50def31d1f81509c9fb5bbb21614d0a22ede8ca4fac5596d73fcb27e8/bayesdesign-0.5.0.tar.gz",
"platform": null,
"description": "# Bayesian Optimal Experiment Design\n\n[![PyPI package](https://img.shields.io/badge/pip%20install-bayesdesign-brightgreen)](https://pypi.org/project/bayesdesign/) [![GitHub Release](https://img.shields.io/github/v/release/dkirkby/bayesdesign?color=green)](https://github.com/dkirkby/bayesdesign/releases) [![Actions Status](https://github.com/dkirkby/bayesdesign/workflows/Test/badge.svg)](https://github.com/dkirkby/bayesdesign/actions) [![License](https://img.shields.io/github/license/dkirkby/bayesdesign)](https://github.com/dkirkby/bayesdesign/blob/main/LICENSE)\n\nUse this package to calculate expected information gain for Bayesian optimal experiment design. For an introduction to this topic, see this [interactive notebook](https://observablehq.com/@dkirkby/boed). To perform a similar calculation with this package, use:\n```python\nfrom bed.grid import Grid, GridStack\nfrom bed.design import ExperimentDesigner\n\ndesigns = Grid(t_obs=np.linspace(0, 5, 51))\nfeatures = Grid(y_obs=np.linspace(-1.25, 1.25, 100))\nparams = Grid(amplitude=1, frequency=np.linspace(0.2, 2.0, 181), offset=0)\n\nsigma_y=0.1\nwith GridStack(features, designs, params):\n y_mean = params.amplitude * np.sin(params.frequency * (designs.t_obs - params.offset))\n y_diff = features.y_obs - y_mean\n likelihood = np.exp(-0.5 * (y_diff / sigma_y) ** 2)\n features.normalize(likelihood)\n\ndesigner = ExperimentDesigner(params, features, designs, likelihood)\n\nprior = np.ones(params.shape)\nparams.normalize(prior);\n\ndesigner.calculateEIG(prior)\n\nplt.plot(designs.t_obs, designer.EIG)\n```\n\nBrowse the [examples folder](https://github.com/dkirkby/bayesdesign/) to learn more about using this package.\n\nTo run the examples in [google colab](https://colab.research.google.com/), select **GitHub** and enter `https://github.com/dkirkby/bayesdesign`.\n\n## Installation\n\nInstall the [latest released version](https://github.com/dkirkby/bayesdesign/releases/latest) from [pypi](https://pypi.org/project/bayesdesign/) using:\n```\npip install bayesdesign\n```\nThe only required dependency is numpy. The optional plot module also requires matplotlib.\n\nThe changes with each version are documented [here](CHANGELOG.md).\n\n## Upgrade\n\nTo upgrade your pip-installed package to the [latest released version](https://github.com/dkirkby/bayesdesign/releases/latest) use:\n```\npip install bayesdesign --upgrade\n```\n\n## Contributing\n\nIf you have feedback or would like to contribute to this package, please see our [contributor's guide](CONTRIBUTING.md).\n",
"bugtrack_url": null,
"license": null,
"summary": "Package for Bayesian optimal experimental design",
"version": "0.5.0",
"project_urls": {
"Bug Reports": "https://github.com/dkirkby/bayesdesign/issues",
"Documentation": "https://github.com/dkirkby/bayesdesign",
"Homepage": "https://github.com/dkirkby/bayesdesign",
"Source Code": "https://github.com/dkirkby/bayesdesign"
},
"split_keywords": [
"bayes",
" optimization"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "c38d86d426e319b8b16438968071d2648929f4f82d4a0cef3459f8538e16f7ff",
"md5": "47d89177efb93ea07a347a58844f5986",
"sha256": "dec2ec0fa53fcba8e1acac42502a906b0f7d6a0d4db236628a30249d4006a9f2"
},
"downloads": -1,
"filename": "bayesdesign-0.5.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "47d89177efb93ea07a347a58844f5986",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 11798,
"upload_time": "2024-12-04T22:53:58",
"upload_time_iso_8601": "2024-12-04T22:53:58.117421Z",
"url": "https://files.pythonhosted.org/packages/c3/8d/86d426e319b8b16438968071d2648929f4f82d4a0cef3459f8538e16f7ff/bayesdesign-0.5.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "0cb496c50def31d1f81509c9fb5bbb21614d0a22ede8ca4fac5596d73fcb27e8",
"md5": "418a2a92e592c5e30e12fba01cffc47f",
"sha256": "e87aadbf1721ce43d6c0e69eca5aa05924295cbd2e35c9116032a7114a14ff1a"
},
"downloads": -1,
"filename": "bayesdesign-0.5.0.tar.gz",
"has_sig": false,
"md5_digest": "418a2a92e592c5e30e12fba01cffc47f",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 15213,
"upload_time": "2024-12-04T22:53:59",
"upload_time_iso_8601": "2024-12-04T22:53:59.096959Z",
"url": "https://files.pythonhosted.org/packages/0c/b4/96c50def31d1f81509c9fb5bbb21614d0a22ede8ca4fac5596d73fcb27e8/bayesdesign-0.5.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-04 22:53:59",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "dkirkby",
"github_project": "bayesdesign",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "numpy",
"specs": []
}
],
"tox": true,
"lcname": "bayesdesign"
}