### Get Parameters in a Specific Parametrization Source: https://pylevy.readthedocs.io/en/latest/levy.html Instantiate a `Parameters` object and use the `get` method to retrieve the parameters in a desired parametrization. This is useful for converting parameters from within an existing `Parameters` object. ```python >>> p = Parameters(par='1', alpha=1.5, beta=0.5, mu=0, sigma=1.2) # to convert >>> p.get('B') # returns the parameters in the parametrization B array([1.5 , 0.59033447, 0.03896531, 1.46969385]) ``` -------------------------------- ### Parameters Class and Conversion Utility Source: https://pylevy.readthedocs.io/en/latest/levy.html Documentation for the Parameters class and its static method 'convert' for transforming Levy stable distribution parameters between different parametrizations. ```APIDOC ## Class Parameters This class is a wrapper for the parameters of the Levy stable distribution. It facilitates fitting by allowing optimization on specific parameters. The primary utility function is `convert`, which transforms parameters between different available parametrizations. ### Class Method: convert Use to convert a parameter array from one parametrization to another. #### Parameters - **pars** (ndarray) - Required - Array of parameters to be converted. - **par_in** (str) - Required - Parametrization of the input array (e.g., '0', '1', 'A', 'B', 'M'). - **par_out** (str) - Required - Parametrization of the output array (e.g., '0', '1', 'A', 'B', 'M'). #### Returns - **ndarray** - Array of parameters in the desired parametrization. #### Examples ```python import numpy as np from pylevy import Parameters a = np.array([1.6, 0.5, 0.3, 1.2]) b = Parameters.convert(a, '1', 'B') print(b) # Expected output: array([1.6 , 0.55457302, 0.2460079 , 1.4243171 ]) c = Parameters.convert(b, 'B', '1') print(c) # Expected output: array([1.6, 0.5, 0.3, 1.2]) np.testing.assert_allclose(a, c) ``` ### Method: get Same as `convert` but used from within a `Parameters` object instance. #### Parameters - **par_out** (str) - Optional - The desired output parametrization (e.g., '0', '1', 'A', 'B', 'M'). If None, returns parameters in the object's current parametrization. #### Returns - **ndarray** - Array of parameters in the specified or object's current parametrization. #### Examples ```python from pylevy import Parameters p = Parameters(par='1', alpha=1.5, beta=0.5, mu=0, sigma=1.2) # to convert print(p.get('B')) # Expected output: array([1.5 , 0.59033447, 0.03896531, 1.46969385]) ``` ``` -------------------------------- ### Convert Parameters Between Parametrizations Source: https://pylevy.readthedocs.io/en/latest/levy.html Use the `convert` class method to transform parameter arrays from one Levy stable distribution parametrization to another. Supported input and output parametrizations include '0', '1', 'A', 'B', and 'M'. ```python >>> a = np.array([1.6, 0.5, 0.3, 1.2]) >>> b = Parameters.convert(a, '1', 'B') >>> b array([1.6 , 0.55457302, 0.2460079 , 1.4243171 ]) >>> c = Parameters.convert(b, 'B', '1') >>> c array([1.6, 0.5, 0.3, 1.2]) >>> np.testing.assert_allclose(a, c) ``` -------------------------------- ### levy.Parameters Class Source: https://pylevy.readthedocs.io/en/latest/genindex.html This section details the methods available for the Parameters class within the levy module. ```APIDOC ## Class levy.Parameters ### Methods - **convert()** - Description: Converts parameters. - Method: (Assumed to be a class method call, specific HTTP method not applicable) - Endpoint: (Not applicable for library methods) - **get()** - Description: Gets parameters. - Method: (Assumed to be a method call, specific HTTP method not applicable) - Endpoint: (Not applicable for library methods) ``` -------------------------------- ### Levy Module API Source: https://pylevy.readthedocs.io/en/latest/_sources/levy.rst.txt Documentation for the core classes and functions within the levy module. ```APIDOC ## levy.Parameters ### Description Class representing the parameters for a Levy distribution. ## levy.random ### Description Generates random numbers following a Levy distribution. ## levy.levy ### Description Calculates values related to the Levy distribution. ## levy.fit_levy ### Description Fits a Levy distribution to a given dataset. ``` -------------------------------- ### Fit Levy Stable Distribution Parameters Source: https://pylevy.readthedocs.io/en/latest/levy.html Estimates the parameters of a Levy stable distribution from data using Maximum Likelihood estimation. Allows fixing specific parameters to restrict the search. ```python >>> np.random.seed(0) >>> x = random(1.5, 0, 0, 1, shape=(200,)) >>> fit_levy(x) # -- Fit a stable distribution to x (par=0, alpha=1.52, beta=-0.08, mu=0.05, sigma=0.99, 402.37150603509247) ``` ```python >>> fit_levy(x, beta=0.0) # -- Fit a symmetric stable distribution to x (par=0, alpha=1.53, beta=0.00, mu=0.03, sigma=0.99, 402.43833088693725) ``` ```python >>> fit_levy(x, beta=0.0, mu=0.0) # -- Fit a symmetric distribution centered on zero to x (par=0, alpha=1.53, beta=0.00, mu=0.00, sigma=0.99, 402.4736618823546) ``` ```python >>> fit_levy(x, alpha=1.0, beta=0.0) # -- Fit a Cauchy distribution to x (par=0, alpha=1.00, beta=0.00, mu=0.10, sigma=0.90, 416.54249079255976) ``` -------------------------------- ### Generate Random Alpha-Stable Variates Source: https://pylevy.readthedocs.io/en/latest/levy.html Generates random values from an alpha-stable distribution using parametrization 0. Can also convert from other parametrizations. ```python >>> rnd = random(1.5, 0, shape=(100,)) # parametrization 0 is implicit >>> par = np.array([1.5, 0.905, 0.707, 1.414]) >>> rnd = random(*Parameters.convert(par ,'B' ,'0'), shape=(100,)) # example with convert ``` -------------------------------- ### Calculate Levy Distribution PDF or CDF Source: https://pylevy.readthedocs.io/en/latest/levy.html Computes the probability density function (PDF) or cumulative distribution function (CDF) for a Levy distribution. Uses parametrization 0 by default. ```python >>> x = np.array([1, 2, 3]) >>> levy(x, 1.5, 0, cdf=True) array([0.75634202, 0.89496045, 0.94840227]) ``` -------------------------------- ### levy Module Functions Source: https://pylevy.readthedocs.io/en/latest/genindex.html This section details the functions available within the levy module. ```APIDOC ## Module levy ### Functions - **fit_levy()** - Description: Fits the Levy distribution. - Method: (Assumed to be a function call, specific HTTP method not applicable) - Endpoint: (Not applicable for library functions) - **levy()** - Description: Generates Levy distribution samples. - Method: (Assumed to be a function call, specific HTTP method not applicable) - Endpoint: (Not applicable for library functions) - **random()** - Description: Generates random Levy distribution samples. - Method: (Assumed to be a function call, specific HTTP method not applicable) - Endpoint: (Not applicable for library functions) ``` -------------------------------- ### levy.levy Source: https://pylevy.readthedocs.io/en/latest/levy.html Calculates the Levy distribution PDF or CDF with the tail replaced by an analytical power law approximation. ```APIDOC ## levy.levy ### Description Computes the Levy distribution at specified values. Supports returning either the PDF or the CDF. ### Parameters - **x** (ndarray) - Required - values where the function is evaluated - **alpha** (float) - Required - alpha - **beta** (float) - Required - beta - **mu** (float) - Optional - mu (default: 0.0) - **sigma** (float) - Optional - sigma (default: 1.0) - **cdf** (bool) - Optional - specifies if it returns the cdf instead of the pdf (default: False) ### Response - **ndarray** - Values of the pdf (or cdf) at x ``` -------------------------------- ### levy.fit_levy Source: https://pylevy.readthedocs.io/en/latest/levy.html Estimates parameters of a Levy stable distribution from data using Maximum Likelihood estimation. ```APIDOC ## levy.fit_levy ### Description Estimate parameters of Levy stable distribution given data x, using Maximum Likelihood estimation. Allows restricting the search by fixing specific parameters. ### Parameters - **x** (ndarray) - Required - values to be fitted - **par** (str) - Optional - parametrization (default: '0') - **kwargs** (dict) - Optional - additional parameters to fix during fitting ### Response - **tuple** - A tuple containing a Parameters object and the negative log likelihood of the data. ``` -------------------------------- ### levy.random Source: https://pylevy.readthedocs.io/en/latest/levy.html Generates random values sampled from an alpha-stable distribution using parametrization 0. ```APIDOC ## levy.random ### Description Generate random values sampled from an alpha-stable distribution. This method is derived directly from the definition of a stable variable and uses parametrization 0. ### Parameters - **alpha** (float) - Required - alpha - **beta** (float) - Required - beta - **mu** (float) - Optional - mu (default: 0.0) - **sigma** (float) - Optional - sigma (default: 1.0) - **shape** (tuple) - Optional - shape of the resulting array ### Response - **ndarray** - Generated random values ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.