virocon.dependencies module

Dependence structures for joint distribution models.

class virocon.dependencies.DependenceFunction(func, bounds=None, constraints=None, weights=None, latex=None, **kwargs)[source]

Bases: object

Function to describe the dependencies between the variables.

The dependence function is a function for the parameters of the dependent variable.

Parameters
  • func (callable) – Dependence functions for the parameter. Maps a conditioning value x and an arbitrary number of parameters to the value of a distributions parameter y. func(x, * args) -> y

  • bounds (list) – Boundaries for parameters of func. Fixed scalar boundaries for func’s parameters. E.g. 0 <= z <= 0 .

  • constraints (dict) – More complex contraints modeled as unequality constraints with functions of the parameters of func z. I.e. c_j(z) >= 0 . For further explanation see: https://docs.scipy.org/doc/scipy-1.6.2/reference/tutorial/optimize.html#sequential-least-squares-programming-slsqp-algorithm-method-slsqp

  • weights (callable, optional) – If given, weighted least squares fitting instead of least squares is used. Defaults to None. Given the data as observation tuples (x_i, y_i) maps from the vector x and y to the vector of weights. E.g. lambda x, y : y to linearly weight the observations with y_i.

  • latex (string, optional) – If given, this string will be used in plots to label the dependence function. It is interpreted as latex and shoul be specified using the same symbols that are used in the function definition. Example: latex=”$a + b * x^{c}$”

Examples

The dependence function is a function for the parameters of the dependent variable. E.g.the zero-up-crossing period is dependent on the significant wave height (Hs|Tp). Assuming, the zero-upcrossing period is lognormally distributed, the parameters mu and sigma are described as functions of the significant wave height (equations given by Haselsteiner et. al(2020) 1 ).

\(\mu_{tz}(h_s) = ln \left(c_1 + c_2 \sqrt{ \frac{h_s)}{ g}} \right)\)

\(\sigma_{tz}(h_s) = c_3 + \frac{c_4)}{1+ c_5h_s}\)

References

1

Haselsteiner, A. F., Sander, A., Ohlendorf, J.-H., & Thoben, K.-D. (2020). Global hierarchical models for wind and wave contours: Physical interpretations of the dependence functions. Proc. 39th International Conference on Ocean, Offshore and Arctic Engineering (OMAE 2020). https://doi.org/10.1115/OMAE2020-18668

callback(caller)[source]

Call to signal, that caller was fitted.

Parameters

caller (DependeneFunction) – The DependenceFunctiom that is now fitted.

fit(x, y)[source]

Determine the parameters of the dependence function.

Parameters
  • x (array-like) – Input data (data consists of n observations (x_i, y_i)).

  • y (array-like) – Target data (data consists of n observations (x_i, y_i)).

Raises

RuntimeError – if the fit fails.

register(dependent)[source]

Register a dependent DependenceFunction. The callback method of all registered dependents is called once this DependenceFunction was fitted.

Parameters

dependent (DependenceFunction) – The DependenceFunctions to register.