Skip to content

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 np.ndarray

Numpy array containing the data.

required
data_min float

Expected minimum value of the data. None by default and computation are made using the minimum value of the data.

None
data_max float

Expected maximum value of the data. None by default and computation are made using the maximum value of the data.

None
weights np.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 np.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 np.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 np.ndarray

Probability weights of data. Provided if all data have not the same importance.

gauss_scores np.ndarray

Data in gaussian space.

hermite_coefficients np.ndarray

Coefficients of hermite polynomials used to transform data from real to gaussian.

data: ndarray property readonly 🍋

Return real data.

Returns:

Type Description
np.ndarray

Array of data.

data_max: float property readonly 🍋

Return maximum of real data.

Returns:

Type Description
float

Maximum value.

data_min: float property readonly 🍋

Return minimum of real data.

Returns:

Type Description
float

Minimum value.

gauss_scores: ndarray property readonly 🍋

Return gaussian score of data.

Returns:

Type Description
np.ndarray

Gaussian scores.

hermite_coefficients: ndarray property readonly 🍋

Return coefficients of Hermite Polynomials transform function.

Returns:

Type Description
np.ndarray

Coefficients of Hermite polynomials.

weights: ndarray property readonly 🍋

Return weights of data.

Returns:

Type Description
np.ndarray

Weights.

compute_hermite_coefficients(self, 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
np.ndarray

Array of n values corresponding to Hermite coefficients.

empirical_inverse_transform(self, x) 🍋

Compute the gaussian inverse anamorphosis of the input array using a linear interpolation of the gaussian scores.

Parameters:

Name Type Description Default
x np.ndarray

Input array containing values in reel space.

required

Returns:

Type Description
np.ndarray

Transformed array = gaussian values.

empirical_transform(self, x) 🍋

Compute the gaussian anamorphosis of the input array using a linear interpolation of the gaussian scores.

Parameters:

Name Type Description Default
x np.ndarray

Input array containing values in gaussian space.

required

Returns:

Type Description
np.ndarray

Transformed array = real values.

theoretical_inverse_transform(self, 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 np.ndarray

Input array containing values in reel space.

required
r float

Change of support coefficient.

1.0

Returns:

Type Description
np.ndarray

Transformed array = gaussian values.

theoretical_transform(self, 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 np.ndarray

Input array containing values in gaussian space.

required
r float

Change of support coefficient.

1.0

Returns:

Type Description
np.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 np.ndarray

numpy array containing the data.

required
weights np.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
np.ndarray

Returns a numpy array that contains the Gaussian scores.

Exceptions:

Type Description
ValueError

Weights have not the same size as the data.

ValueError

Some weights are negative.

Warning

Weights are normalized if they do not sum up to 1.

Back to top