paddy.Default_Numerics module¶
The paddy.Default_Numerics
module contains functions for numeric
problems.
Routine listings¶
eval_numeric(object)
polynomial(object)
poly(x,seed)
trig_inter(x,seed)
mse_func(target, output)
gramacy_lee()
See Also¶
Notes¶
The background information regarding how general functions and classes used to
initiate an instance of PFARunner
that are also
provided as builtins in the Default_Numerics
module is described
in the Paddy_Runner
module.
Examples¶
-
class
paddy.Default_Numerics.
EvalNumeric
(error_func=<function mse_func>, t_func=<function gramacy_lee>, f_func=<function trig_inter>)[source]¶ Bases:
object
Return error after evaluating a numeric function.
This class can be used to evaluate an optimization problem where fiting to a numeric value is the goal. This can range from interpolation to min-max optimization.
- Parameters
- seedarray-like, shape = (parameters,2)
A numpy array of parameters generated by paddy. Refer to
Paddy_runner
for details regarding generation of the array.- error_funcfunction, optional (default
An error function thats output is minimized by paddy. If user defined , make sure to note the internal sign change used to maximize the negative error value returned by eval_numeric.
- t_funcfunction, optional (default
A target function that provides the input and target value(s) for the error and fitting functions.
- f_funcfunction, optional (default
A fitting function that recieves an input generated by the target function, and returns an output to compate with the desired answer being optimized twards.
- Returns
- errorfloat
A numeric value that serves as the fitness value for the seed evaluated. This is defined as the negative output of the error function.
See also
Notes
The default functionalities of this function is evaluation of seed values as the coeficents of a trigonometric polynomial used to interpolate the Gramacy and Lee function, where the evaluation metric function is the mean squared error of the x-y coordinates of Gramacy and Lee and the generated polynomial where \(x\in[ -0.5,2.5 ]\) with a resolution of 0.001. The default and user defined instances of this class use the method eval(seed) to evaluate and return results.
Methods
eval
(self, seed)Method of eval_numeric.
-
class
paddy.Default_Numerics.
Polynomial
(length, scope, gausian_type, normalization=True, limits=True)[source]¶ Bases:
object
Generate paddy space that is apt for polynomial fitting.
See also
eval_numeric
paddy.Paddy_Parameter.PaddyParameter
-
paddy.Default_Numerics.
gramacy_lee
()[source]¶ Return Gramacy and Lee function coordinates.
This function generates the x-y coordinates used to evaluate interpolation of the Gramacy and Lee function via a default or user defined intrerpolation function.
See also
eval_numeric()
References
- 1
Gramacy, R. B., & Lee, H. K. (2012). Cases for the nugget in modeling computer experiments. Statistics and Computing, 22(3), 713-722 .
-
paddy.Default_Numerics.
mse_func
(target, mse_input)[source]¶ Return error of interpolation.
This function returns eval_numeric()the mean squared error for two sequences of numeric values.
-
paddy.Default_Numerics.
poly
(x_list, seed)[source]¶ Return cordinates of a polynomial.
This function returns the 2-D cordinates of a polynomial, and is used for interpolation problems.
- Parameters
- x_listlist
A list of numerics that defines the x values evaluated over.
- seedarray-like, shape = (parameters, 2)
A numpy array of parameters generated by paddy. Refer to
Paddy_runner
for details regarding generation of the array.
- Returns
- outputlist of floats
A list of float values representing the y values of the input x.
See also
eval_numeric()
Notes
The polynomial is defined as:
\[\sum_{k=0}^{n}a_{k}x^k\]Where
a
represents the sequence of parameter values generated by paddy.x
is simply the x parameter of numeric values that the polynomial is evaluated over.
-
paddy.Default_Numerics.
trig_inter
(x_list, seed)[source]¶ Return cordinates of a trigonometric polynomial.
This function returns the 2-D cordinates of a trigonometric polynomial, and is used for interpolation problems.
- Parameters
- x_listlist
A list of numerics that defines the x values evaluated over.
- seedarray-like, shape = (parameters,2)
A numpy array of parameters generated by paddy. Refer to
Paddy_runner
for details regarding generation of the array.
See also
eval_numeric()
Notes
The trigonometric polynomial is defined as:
\[t(x)=a_{0}+\sum_{n=1}^{N}a_{n}\cos(nx)+\sum_{n=1}^{N}b_{n}\sin( nx)\]Where
a
represents the sequence of parameter values generated by paddy and are passed as the odd indices of seed andb
being even. Notice that this would mean that a trigonometric polynomial of the 10th degree would be defined by a paddy space of 11 individual parameters.