Anamorphosis🍋
Anamorphosis
🍋
Anamorphosis class.
Allows to transform skew data into standardize data. Transformation is bijective in the interval defined by the data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
ndarray
|
Numpy array containing the data. |
required |
data_min |
Optional[float]
|
Expected minimum value of the data. None by default and computation are made using the minimum value of the data. |
None
|
data_max |
Optional[float]
|
Expected maximum value of the data. None by default and computation are made using the maximum value of the data. |
None
|
weights |
Optional[ndarray]
|
Numpy array containing the probability weights associated to each interval defined by the order statisticals of the data in order to determine the Gaussian scores. By default None, which implies uniform probability weights (see gauss_score function). |
None
|
gauss_scores |
Optional[ndarray]
|
Option to use the Gaussian scores of the sample as an input directly. By default None. If None, the Gaussian scores will be obtained by this function. If the Gaussian scores are given as an input, they are supposed to be sorted by score. This condition is not verified by this function. |
None
|
Attributes:
Name | Type | Description |
---|---|---|
data |
ndarray
|
Data in real space. |
data_min |
float
|
Minimum possible value data. Specified when values can be smaller than observed. |
data_max |
float
|
Maximum possible value data. Specified when values can be grater than observed. |
weights |
ndarray
|
Probability weights of data. Provided if all data have not the same importance. |
gauss_scores |
ndarray
|
Data in gaussian space. |
hermite_coefficients |
ndarray
|
Coefficients of hermite polynomials used to transform data from real to gaussian. |
data_max: float
property
🍋
data_min: float
property
🍋
gauss_scores: np.ndarray
property
🍋
hermite_coefficients: np.ndarray
property
🍋
Return coefficients of Hermite Polynomials transform function.
Returns:
Type | Description |
---|---|
ndarray
|
Coefficients of Hermite polynomials. |
weights: np.ndarray
property
🍋
compute_hermite_coefficients(n, error=False)
🍋
Compute coefficients of Hermite polynomials based on a number of polynomials.
Function to obtain the Hermite coefficients of a Gaussian anamorphose model function. The anamorphose used is a continuous piece-wise linear function constructed from the Gaussian scores of the sample data according to weights, together with maximum and minimum optional conditions.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n |
int
|
Order of the Hermite approximation. |
required |
error |
bool
|
If True, the approximation error (L2 norm with Gaussian weight) will be retourned as a second element of the output list. False by default. |
False
|
Returns:
Type | Description |
---|---|
ndarray
|
Array of n values corresponding to Hermite coefficients. |
empirical_inverse_transform(x)
🍋
empirical_transform(x)
🍋
theoretical_inverse_transform(x, r=1.0)
🍋
Compute the gaussian inverse anamorphosis of the input array using an interpolation with Hermite polynomials of the gaussian scores. Obtained values are approximates from results of transform gausian values.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x |
ndarray
|
Input array containing values in reel space. |
required |
r |
float
|
Change of support coefficient. |
1.0
|
Returns:
Type | Description |
---|---|
ndarray
|
Transformed array = gaussian values. |
theoretical_transform(x, r=1.0)
🍋
Compute the gaussian anamorphosis of the input array using an interpolation with Hermite polynomials of the gaussian scores.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x |
ndarray
|
Input array containing values in gaussian space. |
required |
r |
float
|
Change of support coefficient. |
1.0
|
Returns:
Type | Description |
---|---|
ndarray
|
Transformed array = real values. |
gauss_score(z, weights=None)
🍋
Function to obtain the (standard) Gaussian scores of a sample.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
z |
ndarray
|
numpy array containing the data. |
required |
weights |
Optional[ndarray]
|
probability weights associated to each interval defined by the order statisticals of the data. Numpy array of size Z.size+1, with non-negative values adding 1 (if not adding 1, they are normalized). weights[j] represent the probability that an anamorphosed standard Gaussian variable according to the empirical cumulative distribution function of Z falls into the interval (Z_(j-1) , Z_(j) ], being Z_(j) the order statistical, j = 1 , ... , N+1, with N the sample size, Z_(0) = -inf, and Z_(N+1) = +inf. If None, a uniform weight vector is used. |
None
|
Returns:
Type | Description |
---|---|
ndarray
|
A numpy array that contains the Gaussian scores. |
Raises:
Type | Description |
---|---|
ValueError
|
|
Warning
Weights are normalized if they do not sum up to 1.