copulas.univariate package¶
Submodules¶
- copulas.univariate.base module
- copulas.univariate.beta module
- copulas.univariate.gamma module
- copulas.univariate.gaussian module
- copulas.univariate.gaussian_kde module
- copulas.univariate.log_laplace module
- copulas.univariate.selection module
- copulas.univariate.student_t module
- copulas.univariate.truncated_gaussian module
- copulas.univariate.uniform module
Module contents¶
Univariate copulas module.
-
class
copulas.univariate.
BetaUnivariate
(random_state=None)[source]¶ Bases:
copulas.univariate.base.ScipyModel
Wrapper around scipy.stats.beta.
Documentation: https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.beta.html
-
BOUNDED
= 2¶
-
MODEL_CLASS
= <scipy.stats._continuous_distns.beta_gen object>¶
-
PARAMETRIC
= 1¶
-
-
class
copulas.univariate.
GammaUnivariate
(random_state=None)[source]¶ Bases:
copulas.univariate.base.ScipyModel
Wrapper around scipy.stats.gamma.
Documentation: https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.gamma.html
-
BOUNDED
= 1¶
-
MODEL_CLASS
= <scipy.stats._continuous_distns.gamma_gen object>¶
-
PARAMETRIC
= 1¶
-
-
class
copulas.univariate.
GaussianKDE
(*args, **kwargs)[source]¶ Bases:
copulas.univariate.base.ScipyModel
A wrapper for gaussian Kernel density estimation.
It was implemented in scipy.stats toolbox. gaussian_kde is slower than statsmodels but allows more flexibility.
When a sample_size is provided the fit method will sample the data, and mask the real information. Also, ensure the number of entries will be always the value of sample_size.
- Parameters
sample_size (int) – amount of parameters to sample
-
BOUNDED
= 0¶
-
MODEL_CLASS
¶ alias of
scipy.stats._kde.gaussian_kde
-
PARAMETRIC
= 0¶
-
cumulative_distribution
(X)[source]¶ Compute the cumulative distribution value for each point in X.
- Parameters
X (numpy.ndarray) – Values for which the cumulative distribution will be computed. It must have shape (n, 1).
- Returns
Cumulative distribution values for points in X.
- Return type
numpy.ndarray
- Raises
NotFittedError – if the model is not fitted.
-
percent_point
(U, method='chandrupatla')[source]¶ Compute the inverse cumulative distribution value for each point in U.
- Parameters
U (numpy.ndarray) – Values for which the cumulative distribution will be computed. It must have shape (n, 1) and values must be in [0,1].
method (str) – Whether to use the chandrupatla or bisect solver.
- Returns
Inverse cumulative distribution values for points in U.
- Return type
numpy.ndarray
- Raises
NotFittedError – if the model is not fitted.
-
probability_density
(X)[source]¶ Compute the probability density for each point in X.
- Parameters
X (numpy.ndarray) – Values for which the probability density will be computed. It must have shape (n, 1).
- Returns
Probability density values for points in X.
- Return type
numpy.ndarray
- Raises
NotFittedError – if the model is not fitted.
-
sample
(*args, **kwargs)¶
-
class
copulas.univariate.
GaussianUnivariate
(random_state=None)[source]¶ Bases:
copulas.univariate.base.ScipyModel
Gaussian univariate model.
-
BOUNDED
= 0¶
-
MODEL_CLASS
= <scipy.stats._continuous_distns.norm_gen object>¶
-
PARAMETRIC
= 1¶
-
-
class
copulas.univariate.
TruncatedGaussian
(*args, **kwargs)[source]¶ Bases:
copulas.univariate.base.ScipyModel
Wrapper around scipy.stats.truncnorm.
Documentation: https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.truncnorm.html
-
BOUNDED
= 2¶
-
MODEL_CLASS
= <scipy.stats._continuous_distns.truncnorm_gen object>¶
-
PARAMETRIC
= 1¶
-
-
class
copulas.univariate.
StudentTUnivariate
(random_state=None)[source]¶ Bases:
copulas.univariate.base.ScipyModel
Wrapper around scipy.stats.t.
Documentation: https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.t.html
-
BOUNDED
= 0¶
-
MODEL_CLASS
= <scipy.stats._continuous_distns.t_gen object>¶
-
PARAMETRIC
= 1¶
-
-
class
copulas.univariate.
Univariate
(*args, **kwargs)[source]¶ Bases:
object
Univariate Distribution.
- Parameters
candidates (list[str or type or Univariate]) – List of candidates to select the best univariate from. It can be a list of strings representing Univariate FQNs, or a list of Univariate subclasses or a list of instances.
parametric (ParametricType) – If not
None
, only select subclasses of this type. Ignored ifcandidates
is passed.bounded (BoundedType) – If not
None
, only select subclasses of this type. Ignored ifcandidates
is passed.random_state (int or np.random.RandomState) – Random seed or RandomState to use.
selection_sample_size (int) – Size of the subsample to use for candidate selection. If
None
, all the data is used.
-
BOUNDED
= 0¶
-
PARAMETRIC
= 0¶
-
cdf
(X)[source]¶ Compute the cumulative distribution value for each point in X.
- Parameters
X (numpy.ndarray) – Values for which the cumulative distribution will be computed. It must have shape (n, 1).
- Returns
Cumulative distribution values for points in X.
- Return type
numpy.ndarray
-
check_fit
()[source]¶ Check whether this model has already been fit to a random variable.
Raise a
NotFittedError
if it has not.- Raises
NotFittedError – if the model is not fitted.
-
cumulative_distribution
(X)[source]¶ Compute the cumulative distribution value for each point in X.
- Parameters
X (numpy.ndarray) – Values for which the cumulative distribution will be computed. It must have shape (n, 1).
- Returns
Cumulative distribution values for points in X.
- Return type
numpy.ndarray
- Raises
NotFittedError – if the model is not fitted.
-
fit
(X)[source]¶ Fit the model to a random variable.
- Parameters
X (numpy.ndarray) – Values of the random variable. It must have shape (n, 1).
-
fitted
= False¶
-
classmethod
from_dict
(params)[source]¶ Build a distribution from its params dict.
- Parameters
params (dict) – Dictionary containing the FQN of the distribution and the necessary parameters to rebuild it. The input format is exactly the same that is outputted by the distribution class
to_dict
method.- Returns
Distribution instance.
- Return type
-
classmethod
load
(path)[source]¶ Load a Univariate instance from a pickle file.
- Parameters
path (str) – Path to the pickle file where the distribution has been serialized.
- Returns
Loaded instance.
- Return type
-
log_probability_density
(X)[source]¶ Compute the log of the probability density for each point in X.
It should be overridden with numerically stable variants whenever possible.
- Parameters
X (numpy.ndarray) – Values for which the log probability density will be computed. It must have shape (n, 1).
- Returns
Log probability density values for points in X.
- Return type
numpy.ndarray
- Raises
NotFittedError – if the model is not fitted.
-
pdf
(X)[source]¶ Compute the probability density for each point in X.
- Parameters
X (numpy.ndarray) – Values for which the probability density will be computed. It must have shape (n, 1).
- Returns
Probability density values for points in X.
- Return type
numpy.ndarray
-
percent_point
(U)[source]¶ Compute the inverse cumulative distribution value for each point in U.
- Parameters
U (numpy.ndarray) – Values for which the cumulative distribution will be computed. It must have shape (n, 1) and values must be in [0,1].
- Returns
Inverse cumulative distribution values for points in U.
- Return type
numpy.ndarray
- Raises
NotFittedError – if the model is not fitted.
-
ppf
(U)[source]¶ Compute the inverse cumulative distribution value for each point in U.
- Parameters
U (numpy.ndarray) – Values for which the cumulative distribution will be computed. It must have shape (n, 1) and values must be in [0,1].
- Returns
Inverse cumulative distribution values for points in U.
- Return type
numpy.ndarray
-
probability_density
(X)[source]¶ Compute the probability density for each point in X.
- Parameters
X (numpy.ndarray) – Values for which the probability density will be computed. It must have shape (n, 1).
- Returns
Probability density values for points in X.
- Return type
numpy.ndarray
- Raises
NotFittedError – if the model is not fitted.
-
sample
(n_samples=1)[source]¶ Sample values from this model.
- Argument:
- n_samples (int):
Number of values to sample
- Returns
Array of shape (n_samples, 1) with values randomly sampled from this model distribution.
- Return type
numpy.ndarray
- Raises
NotFittedError – if the model is not fitted.
-
save
(path)[source]¶ Serialize this univariate instance using pickle.
- Parameters
path (str) – Path to where this distribution will be serialized.
-
set_random_state
(random_state)[source]¶ Set the random state.
- Parameters
random_state (int, np.random.RandomState, or None) – Seed or RandomState for the random generator.
-
to_dict
()[source]¶ Return the parameters of this model in a dict.
- Returns
Dictionary containing the distribution type and all the parameters that define the distribution.
- Return type
dict
- Raises
NotFittedError – if the model is not fitted.
-
class
copulas.univariate.
ParametricType
[source]¶ Bases:
enum.Enum
Parametric Enum.
-
NON_PARAMETRIC
= 0¶
-
PARAMETRIC
= 1¶
-
-
class
copulas.univariate.
BoundedType
[source]¶ Bases:
enum.Enum
Bounded Enum.
-
BOUNDED
= 2¶
-
SEMI_BOUNDED
= 1¶
-
UNBOUNDED
= 0¶
-
-
class
copulas.univariate.
UniformUnivariate
(random_state=None)[source]¶ Bases:
copulas.univariate.base.ScipyModel
Uniform univariate model.
-
BOUNDED
= 2¶
-
MODEL_CLASS
= <scipy.stats._continuous_distns.uniform_gen object>¶
-
PARAMETRIC
= 1¶
-
-
class
copulas.univariate.
LogLaplace
(random_state=None)[source]¶ Bases:
copulas.univariate.base.ScipyModel
Wrapper around scipy.stats.loglaplace.
Documentation: https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.loglaplace.html
-
BOUNDED
= 1¶
-
MODEL_CLASS
= <scipy.stats._continuous_distns.loglaplace_gen object>¶
-
PARAMETRIC
= 1¶
-