Skip to main content

Entropy from discrete data

Project description

## ndd - entropy from discrete data.

The **ndd** module is a minimal Python interface to the Nemenman-Schafee-Bialek
(NSB) algorithm, a parameter-free, Bayesian entropy estimator for discrete data.

## Basic usage

The `ndd.entropy()` function takes as input a vector of counts
(the observed frequencies for a set of classes or states)
and returns an entropy estimate (in nats):

```python
>>> counts
[7, 3, 5, 8, 9, 1, 3, 3, 1, 0, 2, 5, 2, 11, 4, 23, 5, 0, 8, 0]
>>> import ndd
>>> entropy_estimate = ndd.entropy(counts)
>>> entropy_estimate
2.623634344902917
```

The posterior standard deviation can be used to quantify the uncertainty in
the entropy estimate. Optionally, `ndd.entropy()` can approximate
the posterior standard deviation:
```python
>>> entropy_estimate, std = ndd.entropy(counts, return_std=True)
>>> std
0.048675500725595504
```

### Where to get it
Install using pip:

```bash
pip install git+https://github.com/simomarsili/ndd.git
```

(add `--user` to install in `~/.local`).
In order to compile **ndd**, you will need `numpy >= 1.8` and a
**Fortran compiler** installed on your machine.
If you are using Debian or a Debian derivative such as Ubuntu,
you can install the gfortran compiler using the following command:

```bash
$ sudo apt-get install gfortran
```

### References

Some refs:

```
@article{wolpert1995estimating,
title={Estimating functions of probability distributions from a finite set of samples},
author={Wolpert, David H and Wolf, David R},
journal={Physical Review E},
volume={52},
number={6},
pages={6841},
year={1995},
publisher={APS}
}

@inproceedings{nemenman2002entropy,
title={Entropy and inference, revisited},
author={Nemenman, Ilya and Shafee, Fariel and Bialek, William},
booktitle={Advances in neural information processing systems},
pages={471--478},
year={2002}
}

@article{nemenman2004entropy,
title={Entropy and information in neural spike trains: Progress on the sampling problem},
author={Nemenman, Ilya and Bialek, William and van Steveninck, Rob de Ruyter},
journal={Physical Review E},
volume={69},
number={5},
pages={056111},
year={2004},
publisher={APS}
}

@article{archer2013bayesian,
title={Bayesian and quasi-Bayesian estimators for mutual information from discrete data},
author={Archer, Evan and Park, Il Memming and Pillow, Jonathan W},
journal={Entropy},
volume={15},
number={5},
pages={1738--1755},
year={2013},
publisher={Multidisciplinary Digital Publishing Institute}
}
```

and interesting links:

- [Sebastian Nowozin on Bayesian estimators](http://www.nowozin.net/sebastian/blog/estimating-discrete-entropy-part-3.html)

- [Il Memming Park on discrete entropy estimators](https://memming.wordpress.com/2014/02/09/a-guide-to-discrete-entropy-estimators/)

### Contributing

**ndd** is an OPEN Source Project so please help out by [reporting bugs](https://github.com/simomarsili/ndd) or forking and opening pull requests when possible.

### License

Copyright (c) 2016,2017, Simone Marsili.
All rights reserved.

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.

Project details


Download files

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

Source Distribution

ndd-0.5.2.tar.gz (40.3 kB view details)

Uploaded Source

File details

Details for the file ndd-0.5.2.tar.gz.

File metadata

  • Download URL: ndd-0.5.2.tar.gz
  • Upload date:
  • Size: 40.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for ndd-0.5.2.tar.gz
Algorithm Hash digest
SHA256 c43f1aecf422abaff9e5e3f076a8d129b82897718f08aa8a0a74dfd0d6b04db4
MD5 c7df11fc761c1cb48c69217f53ec33a9
BLAKE2b-256 3d8b8e0527ea4b2811c36847a52f6a30686b4dc86570d7edd9ea21bdb86c5d04

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page