Skip to content

Commit

Permalink
mvgaussian uncertainties bugfix (0.3.1 release) (#8)
Browse files Browse the repository at this point in the history
* fix to treat mvgaussian uncertainties from percentiles like other distribution types
  • Loading branch information
kecnry authored Apr 23, 2021
1 parent 5ad2aa2 commit 50edc95
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 41 deletions.
41 changes: 1 addition & 40 deletions distl/distl.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
else:
_has_dill = True

__version__ = '0.3.0'
__version__ = '0.3.1'
version = __version__

_math_symbols = {'__mul__': '*', '__add__': '+', '__sub__': '-',
Expand Down Expand Up @@ -6737,45 +6737,6 @@ def ndimensions(self):
"""
return len(self.mean)


def uncertainties(self, sigma=1, tex=False, dimension=None):
"""
Expose (symmetric) uncertainties for the distribution(s) at a given
value of `sigma` directly from <MVGaussian.mean> and <MVGaussian.cov>.
Arguments
-----------
* `sigma` (int, optional, default=1): number of standard deviations to
expose.
* `tex` (bool, optional, default=False): return as a formatted latex
string.
* `dimension` (int or string, optional, default=None): the label or index
of the dimension to use.
Returns
---------
* if not `tex`: a list of triplets where each triplet is lower, median, upper
* if `tex`: <Latex> object with <Latex.as_latex> and <Latex.as_string> properties.
"""

if dimension is None:
dimensions = range(self.ndimensions)
else:
dimensions = [self._get_dimension_index(dimension)]

if tex:
labels = [self.labels[d] if self.labels is not None else None for d in dimensions]
labels_latex = [self.labels_latex[d] if self.labels is not None else None for d in dimensions]
units = [self.units[d] if self.units is not None else None for d in dimensions]
means = [self.mean[d] for d in dimensions]
diagonal = self.cov.diagonal()
diagonals = [diagonal[d]*sigma for d in dimensions]
return _format_uncertainties_symmetric(labels, labels_latex, units, means, diagonals)
else:
return [[self.mean[i]-self.cov[i][i]*sigma, self.mean[i], self.mean[i]+self.cov[i][i]*sigma] for i in dimensions]


def slice(self, dimension):
"""
Take a single dimension from the multivariate distribution while
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
long_description = fh.read()

setup(name='distl',
version='0.3.0',
version='0.3.1',
description='Simple Distributions: math operations, serializing, covariances',
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down

0 comments on commit 50edc95

Please sign in to comment.