nws_tools.
mutual_info
(tsdata, n_bins=32, normalized=True, fast=True, norm_ts=True)[source]¶Calculate a (normalized) mutual information matrix at zero lag
Parameters: | tsdata : NumPy 2d array
n_bins : int
normalized : bool
fast : bool
norm_ts : bool
|
---|---|
Returns: | mi : NumPy 2d array
|
See also
pyunicorn.pyclimatenetwork.mutual_info_climate_network
Notes
For two random variables \(X\) and \(Y\) the raw mutual information is given by
where \(H(X)\) and \(H(Y)\) denote the Shannon entropies of \(X\) and \(Y\), respectively, and \(H(X,Y)\) is their joint entropy. By default, this function normalizes the raw mutual information \(MI(X,Y)\) by the geometric mean of \(H(X)\) and \(H(Y)\)
The heavy lifting in this function is mainly done by code parts taken from the pyunicorn package, developed by Jonathan F. Donges and Jobst Heitzig [R9]. It is currently available here The code has been modified so that weave and pure Python codes are now part of the same function. Further, the original code computes the raw mutual information only. Both Python and C++ parts have been extended to compute a normalized mutual information too.
References
[R9] | (1, 2) Copyright (C) 2008-2015, Jonathan F. Donges (Potsdam-Institute for Climate Impact Research), pyunicorn authors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
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. |
Examples
>>> tsdata = np.random.rand(150,2) # 2 time-series of length 150
>>> NMI = mutual_info(tsdata)