qp_flexzboost
Submodules
Package Contents
Classes
This enumerates the various basis systems that FlexCode supports |
|
Distribution based on weighted basis functions output from FlexZBoost. |
Attributes
- class BasisSystem[source]
Bases:
enum.EnumThis enumerates the various basis systems that FlexCode supports
- Parameters:
Enum (enum) – This enum inherits from the Enum class.
- cosine = 1
- Fourier = 2
- db4 = 3
- class FlexzboostGen(weights: List[List[float]], basis_system_enum_value: int, z_min: float, z_max: float, bump_threshold: float, sharpen_alpha: float, *args, **kwargs)[source]
Bases:
qp.pdf_gen.Pdf_rows_genDistribution based on weighted basis functions output from FlexZBoost.
Notes
This class is meant primarily to be a compact storage mechanism for output from FlexCode.
- property basis_system_enum: BasisSystem
Return the BasisSystem enum for this object.
- Returns:
The BasisSystem enum that defines the basis system used for these results.
- Return type:
- property z_min: float
Return the minimum z value used for the results stored in this object.
- Returns:
Minimum z value used to predict these results
- Return type:
float
- property z_max: float
Return the maximum z value used for the results stored in this object.
- Returns:
Maximum z value used to predict these results
- Return type:
float
- property bump_threshold: float
Return the bump threshold used for the results stored in this object.
- Returns:
Bump threshold value used to predict these results
- Return type:
float
- property sharpen_alpha: float
Return the sharpen alpha used for the results stored in this object.
- Returns:
Sharpen alpha value used to predict these results
- Return type:
float
- property basis_coefficients: flexcode.basis_functions.BasisCoefs
Return the BasisCoef object that was used to instantiate this object.
- Returns:
Object used to initialize the class instance
- Return type:
BasisCoefs
- name = 'flexzboost'
- version = 0
- _support_mask
- _build_basis_coef_object()
Private method that builds and returns a FlexCode:BasisCoefs object from the constructor parameters.
- Returns:
Object used to initialize the class instance
- Return type:
BasisCoefs
- _update_basis_coef_object()
Simple method to update the BasisCoefs object ‘in place’.
- _calculate_yvals_if_needed(xvals: List[float]) None
If self._yvals is None or the xvals have changed, reevaluate the y values.
- Parameters:
xvals (List[float]) – The x-values to evaluate the basis function.
- _evaluate_basis_coefficients(xvals: List[float]) None
Assign the list of x values to self._xvals. Use that grid to evaluate the y_values of PDFs using the weights and parameters stored in self._basis_coefficients.
- Parameters:
xvals (List[float]) – The x-values to evaluate the analytical PDFs
Notes
We’ll maintain a copy of the x values in memory for this object, but it won’t be stored to disk.
FlexCode requires that the x values be reshaped, we’ll do that in the call to .evaluate, but we won’t keep the reshaped x values in memory.
The .evaluate method expects the BasisCoefs object to contain the output weights. So we’ll add the weights back to the object for evaluation, and then remove them when we’ve completed evaluation. We do this to ensure that the value of weights is not accidentally stored to disk twice. Once as self._weights, and once as self._basis_coefficients.coefs.
If storage to disk wasn’t a concern, then this wouldn’t be a problem. Due to the way that Python maintains references to values in memory, assigning the same values to self._weights and self._basis_coefficients.coefs doesn’t actually use 2x the memory.
- _compute_ycumul(xvals: List[float]) None
Compute the cumulative values of y given an x grid
- Parameters:
xvals (List[float]) – The x-values to evaluate the cumulative y value.
- _pdf(x: List[float], row: List[int]) List[List[float]]
Return the numerical PDFs, evaluated on the grid, x.
- Parameters:
x (List[float]) – The x-values to evaluate the analytical PDFs
row (List[int], optional) – The indices for which numerical PDFs should be generated
- Returns:
A list of lists corresponding to individual PDF’s y-values. Each of the outer lists is a single PDF. The elements of the inner list are the resulting y-values corresponding to the input x-values.
- Return type:
List[List[float]]
- _cdf(x: List[float], row: List[int]) List[List[float]]
Return the numerical CDF, evaluated on the grid, x.
- Parameters:
x (List[float]) – The x-values to evaluate the analytical CDFs
row (List[int], optional) – The indices for which numerical CDFs should be generated
- Returns:
A list of lists corresponding to individual CDF’s y-values. Each of the outer lists is a single CDF. The elements of the inner list are the resulting y-values corresponding to the input x-values.
- Return type:
List[List[float]]
- _ppf(x: List[float], row: List[int]) List[List[float]]
Return the numerical PPF, evaluated on the grid, x.
- Parameters:
x (List[float]) – The x-values to evaluate the analytical PPFs
row (List[int], optional) – The indices for which numerical PPFs should be generated
- Returns:
A list of lists corresponding to individual PPF’s y-values. Each of the outer lists is a single PPF. The elements of the inner list are the resulting y-values corresponding to the input x-values.
- Return type:
List[List[float]]
- _updated_ctor_param()
Specify the constructor parameters. This is required by scipy in order extend the rv_continuous class.
- Returns:
Dictionary of the constructor arguments and object instance variables needed to create this object.
- Return type:
dct dict
- classmethod create_from_basis_coef_object(weights: List[List[float]], basis_coefficients_object: flexcode.basis_functions.BasisCoefs, **kwargs) qp.pdf_gen.Pdf_rows_gen
This is a convenience method that allows the user to define a generator by passing a BasisCoefs object, instead of the typical 5 additional values.
- Parameters:
weights (List[List[float]]) – A list of lists were each element is a floating point value. The weights represent the contribution of each basis function to the final PDF. The shape of weights should be N x b, where N = number of PDFs and b = number of basis functions.
basis_coefficients (BasisCoefs) – An object that contains the FlexZBoost output weights as well as the parameters required to define the set of basis functions.
- Returns:
Returns an instance of this class. Note that FlexzboostGen is a subclass of Pdf_rows_gen, the return type defined in the method signature.
- Return type:
- classmethod get_allocation_kwds(npdf, **kwargs)
Return the keywords necessary to create an ‘empty’ hdf5 file with npdf entries for iterative file write out. We only need to allocate the objdata columns, as the metadata can be written when we finalize the file.
- Parameters:
npdf (int) – The total number of PDFs that will be written out
- Returns:
A dictionary that defines the storage requirements for this object.
- Return type:
dict
- classmethod plot_native(pdf, **kwargs)
Plot the PDF in a way that is particular to this type of distribution
Here we’ll use interpolated x,y points derived from the weights and FlexCode evaluation parameters.
- classmethod add_mappings()
Add this classes mappings to the conversion dictionary
- classmethod make_test_data()
Make data for unit tests