pystra.distributions.typeiilargestvalue.TypeIIlargestValue#
- class TypeIIlargestValue(name, mean, stdv, input_type=None, startpoint=None)[source]#
Bases:
DistributionType II largest value distribution
- Attributes:
name (str): Name of the random variable
mean (float): Mean or u_n
stdv (float): Standard deviation or k
input_type (any): Change meaning of mean and stdv
startpoint (float): Start point for seach
Methods
Cumulative distribution function.
Derivatives of the CDF w.r.t.
getMeangetNamegetStartPointgetStdvDiagonal Jacobian of the marginal x-to-u transformation.
Probability density function.
Plot the probability density function.
Percent-point function (inverse CDF).
Draw random samples from the distribution.
setStartPointUpdate the location parameter of the underlying SciPy distribution.
Update the scale parameter of the underlying SciPy distribution.
typIIlargest_parameterTransform from standard normal space to physical space.
Transform from physical space to standard normal space.
- cdf(x)#
Cumulative distribution function.
- Parameters:
x (float or array_like) – Value(s) in physical space.
- Returns:
Probability value(s) in [0, 1].
- Return type:
float or ndarray
- dF_dtheta(x)#
Derivatives of the CDF w.r.t. each sensitivity parameter.
Returns
∂F_X(x)/∂θfor every parameter listed bysensitivity_params. The base-class implementation uses central finite differences on the CDF via_make_copy().Before computing derivatives, a reconstruction sanity check verifies that
_make_copy()(with no overrides) reproduces the current distribution. This catches both constructor failures (e.g. composite distributions) and silent mismatches (e.g. distributions whose extra constructor arguments are not stored in_ctor_kwargs).Subclasses may override this with analytical expressions for better accuracy and performance (see
NormalandLognormal).- Parameters:
x (float) – Evaluation point in physical space.
- Returns:
{param_name: ∂F/∂θ}for each parameter insensitivity_params.- Return type:
dict
- Raises:
ValueError – If the distribution cannot be faithfully reconstructed by
_make_copy().
- jacobian(u, x)#
Diagonal Jacobian of the marginal x-to-u transformation.
Returns a diagonal matrix
Jwhere the diagonal entry isf_X(x) / phi(u)(Lemaire, eq. 4.9). This is assembled into the full Jacobian by theTransformationclass.- Parameters:
u (float or array_like) – Value(s) in standard normal space.
x (float or array_like) – Corresponding value(s) in physical space.
- Returns:
Diagonal Jacobian matrix of shape
(n, n)where n is the length of the input arrays.- Return type:
ndarray
- pdf(x)#
Probability density function.
- Parameters:
x (float or array_like) – Value(s) in physical space.
- Returns:
Density value(s).
- Return type:
float or ndarray
- plot(ax=None, **kwargs)#
Plot the probability density function.
- Parameters:
ax (matplotlib.axes.Axes, optional) – Axes to plot on. A new figure is created if
None.**kwargs – Additional keyword arguments forwarded to
ax.plot().
- Returns:
The axes containing the plot.
- Return type:
matplotlib.axes.Axes
- ppf(u)#
Percent-point function (inverse CDF).
- Parameters:
u (float or array_like) – Probability value(s) in (0, 1).
- Returns:
Quantile(s) in physical space.
- Return type:
float or ndarray
- sample(n=1000)#
Draw random samples from the distribution.
Uses inverse-transform sampling via
ppf.- Parameters:
n (int, optional) – Number of samples (default 1000).
- Returns:
Array of shape
(n,)with sampled values.- Return type:
ndarray
- property sensitivity_params#
Distribution parameters for which sensitivities are computed.
Returns a dict
{param_name: current_value}listing every parameter with respect to which \(\partial\beta/\partial\theta\) should be evaluated.The default implementation returns
{"mean": μ, "std": σ}, which is appropriate for most distributions. Distributions with additional parameters of interest (e.g. the GEV shape parameter) should override this property to include them.Parameters listed in
_ctor_kwargsbut not insensitivity_paramsare held fixed during sensitivity analysis — they are only used by_make_copy()to faithfully reconstruct the distribution.- Returns:
{param_name: current_value}- Return type:
dict
- set_location(loc=0)#
Update the location parameter of the underlying SciPy distribution.
After updating,
meanandstdvare recomputed. This is used by the sensitivity analysis to perturb distribution parameters.- Parameters:
loc (float, optional) – New location parameter (default 0).
- Raises:
Exception – If the distribution does not wrap a SciPy frozen distribution.
- set_scale(scale=1)#
Update the scale parameter of the underlying SciPy distribution.
After updating,
meanandstdvare recomputed. This is used by the sensitivity analysis to perturb distribution parameters.- Parameters:
scale (float, optional) – New scale parameter (default 1).
- Raises:
Exception – If the distribution does not wrap a SciPy frozen distribution.
- u_to_x(u)#
Transform from standard normal space to physical space.
Applies the marginal Nataf mapping:
x = F^{-1}(Phi(u)).- Parameters:
u (float) – Value in standard normal (u) space.
- Returns:
Corresponding value in physical (x) space.
- Return type:
float
- x_to_u(x)#
Transform from physical space to standard normal space.
Applies the marginal Nataf mapping:
u = Phi^{-1}(F(x)).- Parameters:
x (float) – Value in physical (x) space.
- Returns:
Corresponding value in standard normal (u) space.
- Return type:
float