Landau¶
-
class
minkit.
Landau
(name, x, center, sigma, backend=None)[source]¶ Bases:
minkit.SourcePDF
Create a Landau PDF with the parameters related to the data, center and scale parameter. The PDF is defined as
\[f\left(x;c,\sigma\right) = \frac{1}{2\pi i \sigma}\int_{a - i \infty}^{a + i \infty} e^{\lambda s + s \log s} ds,\]where \(\lambda = \frac{x - c}{\sigma}\) and a is an arbitrary parameter.
- Parameters
Attributes Summary
All the argument parameters associated to this class.
All the parameters associated to this class.
All the argument parameters that are not
ParameterFormula
instances.Object to do operations on arrays.
Argument parameters this object directly depends on.
Backend interface.
Return the cached values for this PDF.
Cache type being used.
Whether this is a constant
PDF
.Data parameters this object directly depends on.
Configuration of the numerical integration method.
Arguments that do not depend on other arguments.
Methods Summary
__call__
(data[, range, normalized])Call the PDF in the given set of data.
bind
([range, normalized])Prepare an object that will be called many times with the same set of values.
copy
([backend])Create a copy of this PDF.
evaluate_binned
(data[, normalized])Evaluate the PDF over a binned sample.
from_json_object
(obj, pars[, backend])Build a PDF from a JSON object.
function
([range, normalized])Evaluate the function.
generate
([size, mapsize, gensize, …])Generate random data.
Get the values of the parameters within this object.
integral
([integral_range, range])Calculate the integral of a
PDF
.norm
([range])Calculate the normalization of the PDF.
numerical_integral
([integral_range, range])Calculate the integral of a
PDF
.numerical_normalization
([range])Calculate a numerical normalization.
Enter a context where the attributes of the parameters will be restored on exit.
set_values
(**kwargs)Set the values of the parameters associated to this PDF.
to_backend
(backend)Initialize this class in a different backend.
Dump the PDF information into a JSON object.
using_cache
(ctype)Safe method to enable a cache of the PDF.
Attributes Documentation
-
BIND
= 'bind'¶
-
CACHE_TYPES
= ('bind', 'const')¶
-
CONST
= 'const'¶
-
all_pars
¶ All the parameters associated to this class. This includes also any
ParameterFormula
and the data parameters.
-
all_real_args
¶ All the argument parameters that are not
ParameterFormula
instances.
-
aop
¶ Object to do operations on arrays.
- Type
-
dependent
= False¶
-
numint_config
¶ Configuration of the numerical integration method.
- Getter
Return a configurable object for the specified numerical integration method.
- Setter
Set the configuration to do a numerical integration from a dictionary.
The dictionary must contain at least the key “method”, and the rest of the keys depend on it:
plain: use a plain Monte Carlo algorithm to evaluate the integral. Use the argument “calls” in order to define the number of calls to do in order to calculate the integral.
miser: use the MISER method of recursive stratified sampling. The possible configuration parameters are:
calls: number of calls to the algorithm.
estimate_frac: fraction of the currently available number of function calls which are allocated to estimating the variance at each recursive step.
min_calls: minimum number of function calls required for each estimate of the variance.
min_calls_per_bisection: minimum number of function calls required to proceed with a bisection step.
alpha: parameter to control how the estimated variances for the two sub-regions of a bisection are combined when allocating points.
dither: parameter that introduces a random fractional variation of size into each bisection.
vegas: use the VEGAS algorithm to evaluate the integral. The possible configuration parameters are:
calls: number of calls to the algorithm.
alpha: parameter to control the stiffness of the rebinning algorithm.
iterations: number of iterations to perform for each call to the routine.
mode: sampling method to use.
In addition, it is possible to define a maximum tolerance for the relative error on the calculation of the integral, which is set through the tolerance key. For more information about the algorithms please consult the Monte Carlo section of the GNU scientific library, at GSL.
Methods Documentation
-
__call__
(data, range='full', normalized=True)¶ Call the PDF in the given set of data.
- Parameters
data (DataSet or BinnedDataSet) – data to evaluate.
range (str) – normalization range.
normalized (bool) – whether to return a normalized output.
- Returns
Evaluation of the PDF.
- Return type
-
bind
(range='full', normalized=True)¶ Prepare an object that will be called many times with the same set of values. This is usefull for PDFs using a cache, to avoid creating it many times in sucessive calls to
PDF.__call__()
.
-
copy
(backend=None)¶ Create a copy of this PDF.
- Parameters
backend (Backend) – new backend.
- Returns
A copy of this PDF.
-
evaluate_binned
(data, normalized=True)¶ Evaluate the PDF over a binned sample.
- Parameters
data (BinnedDataSet) – input data.
normalized (bool) – whether to normalize the output array or not.
- Returns
Values from the evaluation.
- Return type
-
classmethod
from_json_object
(obj, pars, backend=None)¶ Build a PDF from a JSON object. This object must represent the internal structure of the PDF.
-
function
(range='full', normalized=True)¶ Evaluate the function.
-
generate
(size=10000, mapsize=1000, gensize=None, safe_factor=1.1, range='full')¶ Generate random data. A call to
PDF.bind()
is implicit, since several calls will be done to the PDF with the same sets of values.- Parameters
size (int) – size (or minimum size) of the output sample.
mapsize (int) – number of points to consider per dimension (data parameter) in order to calculate the maximum value of the PDF.
gensize (int) – number of entries to generate per iteration.
safe_factor (float) – additional factor to multiply the numerically calculated maximum of the function. In general this must be modified if the function is not well-behaved.
range (str) – range of the data parameters where to generate data.
- Returns
Output sample.
- Return type
-
get_values
()¶ Get the values of the parameters within this object.
-
norm
(range='full')¶ Calculate the normalization of the PDF.
-
numerical_normalization
(range='full')¶ Calculate a numerical normalization.
-
restoring_state
()¶ Enter a context where the attributes of the parameters will be restored on exit.
-
set_values
(**kwargs)¶ Set the values of the parameters associated to this PDF.
Note
Any PDF sharing parameters with this will also change its behaviour.
-
to_backend
(backend)¶ Initialize this class in a different backend.
- Parameters
backend (Backend) – new backend.
- Returns
An instance of this class in the new backend.
-
to_json_object
()¶ Dump the PDF information into a JSON object. The PDF can be constructed at any time by calling
PDF.from_json_object()
.- Returns
Object that can be saved into a JSON file.
- Return type
-
using_cache
(ctype)¶ Safe method to enable a cache of the PDF. There are two types of cache:
const: it means that we plan to call the
PDF
consecutively in the same data set, but the value of the parameters that are not constant is allowed to change. This means that anyPDF
that has all its arguments as constant is assumed to have the same value in each evaluation.bind: this is reserved for those processes where the normalization range will be the same, as well as the values of the parameters of the
PDF
. However, the function can be called in different data sets.
Warning
It is responsibility of the user to ensure that the conditions for the cache to be valid are preserved.
- Parameters
ctype (str) – cache type.