fips.covariance.CorrelationModel.with_std#
- CorrelationModel.with_std(std)[source]#
Return the covariance of this correlation with standard deviations std.
- Overloads:
std (
Vector) →Covariancestd (
float|Series) →CovarianceModel
Entry
(i, j)isstd[i] * C[i, j] * std[j]. This is the one way to make a covariance from a model.- Parameters:
std (
float|Series|Vector) – The standard deviation of each label, not negative. A number is the same for every label. A Series is indexed by the labels of the one block the covariance is built on, without ablocklevel (vector["flux"]’s labels,space.select("flux")), and is lined up with them by label when the model is built. AVectorbrings its own space. A plain array is refused: it has no labels, so nothing would say which value is whose.- Returns:
For a Vector, the
Covarianceon its space. For a number or a Series, aCovarianceModel, whichbuild()puts on a space.- Return type:
- Raises:
TypeError – If std is an array, a list or anything else that is not a number, a Series or a Vector.
ValueError – If a standard deviation is negative or not finite, or the Series’ index has a
blocklevel, an unnamed level or a label twice.
See also
fips.covariance.CovarianceModel.buildPut the model on a space.
Examples
>>> import pandas as pd >>> from fips import Exponential, Space, Vector >>> x = pd.Index([0.0, 1.0, 2.0], name="x") >>> space = Space({"flux": x}) >>> S = Exponential("x", 1.0).with_std(2.0).build(space) >>> S.dense().round(3) array([[4. , 1.472, 0.541], [1.472, 4. , 1.472], [0.541, 1.472, 4. ]])
A Series is read by label, whatever its order:
>>> std = pd.Series([2.0, 1.0, 1.0], index=x[::-1]) >>> Exponential("x", 1.0).with_std(std).build(space).variances.values array([1., 1., 4.])
A Vector is a covariance at once:
>>> std = Vector([1.0, 1.0, 2.0], space) >>> Exponential("x", 1.0).with_std(std).variances.values array([1., 1., 4.])