Copyright(c) Fabricio Olivetti de Franca 2020
LicenseGPL-3
Maintainerfabricio.olivetti@gmail.com
Stabilityexperimental
PortabilityPOSIX
Safe HaskellNone

IT.Eval

Description

Definition of functions pertaining to the conversion and evaluation of an IT-expression.

TODO: move interval evaluation to IT.Eval.Interval

Synopsis

Documentation

log1p :: Floating a => a -> a Source #

log(x+1)

Evaluation of the Transformation functions

transform :: Floating a => Transformation -> a -> a Source #

Evaluate the transformation function f in a data point x.

derivative :: Floating a => Transformation -> a -> a Source #

Evaluate the derivative of a transformation function.

sndDerivative :: Floating a => Transformation -> a -> a Source #

Evaluate the second derivative of the transformation function.

polynomial :: Dataset Double -> Interaction -> Column Double Source #

Evaluates the interaction ks in the dataset xss

It folds the map of exponents with the key, retrieve the corresponding column, calculates x_i^k_i and multiplies to the accumulator. It return a column vector.

polynomialInterval :: [Interval Double] -> Interaction -> Interval Double Source #

Evaluates the interval of the interaction w.r.t. the domains of the variables.

In this case it is faster to fold through the list of domains and checking whether we have a nonzero strength.

evalTerm :: Dataset Double -> Term -> Column Double Source #

Evaluates a term by applying the transformation function to the result of the interaction.

evalTermInterval :: [Interval Double] -> Term -> Interval Double Source #

Evaluates the term on the interval domains.

evalTermDiff :: Int -> Dataset Double -> Term -> Column Double Source #

The partial derivative of a term w.r.t. the variable ix is:

If ix exists in the interaction, the derivative is: derivative t (polynomial xss ks) * (polynomial xss ks') ks' is the same as ks but with the strength of ix decremented by one Otherwise it is equal to 0

Given the expression: w1 t1(p1(x)) + w2 t2(p2(x)) The derivative is: w1 t1'(p1(x))p1'(x) + w2 t2'(p2(x))p2'(x)

evalTermSndDiff :: Int -> Int -> Dataset Double -> Term -> Column Double Source #

The second partial derivative of a term w.r.t. the variables ix and iy is:

given p(x) as the interaction function, t(x) the transformation function, f'(x)|i the first derivative of a function given i and f''(x) the second derivative.

If iy exists in p(x) and ix exists in p'(x)|iy, the derivative is:

kx*ky*t''(x)*p'(x)|ix * p'(x)|iy + kxy*t'(x)p''(x)

where kx, ky are the original exponents of variables ix and iy, and kxy is ky * kx', with kx' the exponent of ix on p'(x)|iy

evalTermDiffInterval :: Int -> [Interval Double] -> Term -> Interval Double Source #

Same as evalTermDiff but optimized for intervals.

evalTermSndDiffInterval :: Int -> Int -> [Interval Double] -> Term -> Interval Double Source #

Same as evalTermSndDiff but optimized for intervals

evalGeneric :: (Dataset Double -> Term -> Column Double) -> Dataset Double -> Expr -> [Double] -> Column Double Source #

evaluates an expression by evaluating the terms into a list applying the weight and summing the results.

evalExpr :: Dataset Double -> Expr -> [Double] -> Column Double Source #

Evaluating an expression is simply applying evalTerm

evalDiff :: Int -> Dataset Double -> Expr -> [Double] -> Column Double Source #

Evaluating the derivative is applying evalTermDiff in the expression

evalSndDiff :: Int -> Int -> Dataset Double -> Expr -> [Double] -> Column Double Source #

Evaluating the second derivative is applying evalTermSndDiff in the expression

evalImageGeneric :: ([Interval Double] -> Term -> Interval Double) -> [Interval Double] -> Expr -> [Double] -> Interval Double Source #

Returns the estimate of the image of the funcion with Interval Arithmetic

this requires a different implementation from evalGeneric

evalImage :: [Interval Double] -> Expr -> [Double] -> Interval Double Source #

evalDiffImage :: Int -> [Interval Double] -> Expr -> [Double] -> Interval Double Source #

evalSndDiffImage :: Int -> Int -> [Interval Double] -> Expr -> [Double] -> Interval Double Source #

isInvalid :: Double -> Bool Source #

A value is invalid if it's wether NaN or Infinite

isValid :: [Double] -> Bool Source #

a set of points is valid if none of its values are invalid and the maximum abosolute value is below 1e150 (to avoid overflow)

exprToMatrix :: Dataset Double -> Expr -> Matrix Double Source #

evaluate an expression to a set of samples

(1 LA.|||) adds a bias dimension

cleanExpr :: Dataset Double -> Expr -> (Expr, Matrix Double) Source #

Clean the expression by removing the invalid terms TODO: move to IT.Regression

notInfNan :: Solution -> Bool Source #

Checks if the fitness of a solution is not Inf nor NaN.

nanInterval :: RealFloat a => Interval a Source #

definition of an interval evaluated to NaN

hasInf :: RealFloat a => Interval a -> Bool Source #

Check if any bound of the interval is infinity

protected :: RealFloat a => (Interval a -> Interval a) -> Interval a -> Interval a Source #

Creates a protected function to avoid throwing exceptions