hep.aida.ref.pdf
Class Function
- java.lang.Object
-
- hep.aida.ref.pdf.Variable
-
- hep.aida.ref.pdf.Function
-
- All Implemented Interfaces:
- IFunction, IModelFunction, FunctionDispatcher, HasName, HasUnits, HasValue, VariableListener
- Direct Known Subclasses:
- Exponential, Gaussian, IFunctionWrapper, NonParametricPdf, Product, Step, Sum
public class Function extends Variable implements IModelFunction, VariableListener, FunctionDispatcher
Base function. Any function should extend this class.
-
-
Constructor Summary
Constructors Constructor and Description Function(java.lang.String name)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidaddFunctionListener(FunctionListener listener)voidaddVariable(Variable v)Variables Management.voidaddVariables(VariableList list)IAnnotationannotation()java.lang.StringcodeletString()String describing the metatype and implementation of the function.intdimension()Dimensionality of the domain space.doubleevaluateAnalyticalNormalization(Dependent dep)doubleevaluateAnalyticalVariableGradient(Variable var)To be overwritten by classes extending Function.voidexcludeNormalizationAll()Set empty range in all axes.doublefunctionMaxValue()This method is used to generate toy Mc data sets.doublefunctionValue()doublefunctionValue(double[] v)DependentgetDependent(int index)DependentgetDependent(java.lang.String parName)ParametergetNormalizationParameter()The normalization Parameter for a function is ALWAYS the last one.ParametergetParameter(int index)ParametergetParameter(java.lang.String parName)double[]gradient()double[]gradient(double[] v)Gradient of the function.booleanhasAnalyticalNormalization(Dependent dep)To be overwritten if Function provides analytical normalization.booleanhasAnalyticalVariableGradient(Variable var)To be overwritten by classes extending Function.voidincludeNormalizationAll()Set full range in all axes.intindexOfParameter(java.lang.String parName)Return -1 if parameter not found (name undefined).booleanisComposite(Variable var)booleanisEqual(IFunction iFunction)Compare if functions are the same.booleanisNormalized()Return true if normalization is currently switched on.java.lang.StringnormalizationParameter()Returns the name of the normalization parameter if the function has one.IRangeSetnormalizationRange(int i)Set the normalization range from -inf to +inf in the i-th axis (dimension).voidnormalizationRangeChanged()voidnormalize(boolean normalize)Normalize by internally adjusting some of the parameters.intnumberOfDependents()intnumberOfParameters()Number of parameters.doubleparameter(java.lang.String parName)double[]parameterGradient()double[]parameterGradient(double[] v)Compute gradient with respect to parameters.java.lang.String[]parameterNames()Names of paramaters.double[]parameters()Retrieve current vector of parameters.booleanprovidesGradient()Determine whether function is able to compute gradient.booleanprovidesGradientWithRespectToVariable(Variable var)booleanprovidesNormalization()booleanprovidesParameterGradient()Return true if provides parameter gradient.voidremoveFunctionListener(FunctionListener listener)voidsetCodeletString(java.lang.String str)voidsetNormalizationParamter(Parameter par)voidsetParameter(java.lang.String parName, double parValue)Set parameter's value by name.voidsetParameters(double[] pars)Set new vector of parameters.voidsetTitle(java.lang.String title)Set the histogram title.voidsetValue(double value)Set the current value.java.lang.Stringtitle()Get the Function's title.doublevalue()Get the current value.doublevalue(double[] v)Scalar value of the function.voidvariableChanged(Variable var)This method is invoked when a variable in the function has changed its value.voidvariableChangedName(Variable var)Method invoked when the Variable's name have changed.voidvariableChangedRange(Variable var)Method invoked when the Variable's range have changed.voidvariableChangedUnits(Variable var)Method invoked when the Variable's Units have changed.voidvariableChangedValue(Variable var)Method invoked when the Variable's value have changed.booleanvariableChangingName(Variable var, java.lang.String name)Method invoked when the Variable's name is about to change.booleanvariableChangingUnits(Variable var, Units units)Method invoked when the Variable's Units are about to change.booleanvariableChangingValue(Variable var, double value)Method invoked when the Variable's value is about to change.java.lang.StringvariableName(int index)Get the symbolic name of i-th variable.java.lang.String[]variableNames()Get all the names in a vector.-
Methods inherited from class hep.aida.ref.pdf.Variable
addVariableListener, name, removeVariableListener, setName, setUnits, type, units
-
-
-
-
Method Detail
-
addVariable
public void addVariable(Variable v)
Variables Management.
-
addVariables
public void addVariables(VariableList list)
-
variableChangingUnits
public boolean variableChangingUnits(Variable var, Units units)
Description copied from interface:VariableListenerMethod invoked when the Variable's Units are about to change.- Specified by:
variableChangingUnitsin interfaceVariableListener- Parameters:
var- The Variable whose Units are changing.units- The new Units for the Variable.- Returns:
trueif the change is allowed.
-
variableChangedUnits
public void variableChangedUnits(Variable var)
Description copied from interface:VariableListenerMethod invoked when the Variable's Units have changed.- Specified by:
variableChangedUnitsin interfaceVariableListener- Parameters:
var- The Variable whose Units have changed.
-
variableChangingValue
public boolean variableChangingValue(Variable var, double value)
Description copied from interface:VariableListenerMethod invoked when the Variable's value is about to change.- Specified by:
variableChangingValuein interfaceVariableListener- Parameters:
var- The Variable whose value is changing.value- The new value for the Variable.- Returns:
trueif the change is allowed.
-
normalizationParameter
public java.lang.String normalizationParameter()
Description copied from interface:IFunctionReturns the name of the normalization parameter if the function has one.- Specified by:
normalizationParameterin interfaceIFunction- Returns:
- The name of the normalization parameter.null if no such parameter is available
-
variableChanged
public void variableChanged(Variable var)
This method is invoked when a variable in the function has changed its value.
-
variableChangedValue
public void variableChangedValue(Variable var)
Description copied from interface:VariableListenerMethod invoked when the Variable's value have changed.- Specified by:
variableChangedValuein interfaceVariableListener- Parameters:
var- The Variable whose value have changed.
-
variableChangingName
public boolean variableChangingName(Variable var, java.lang.String name)
Description copied from interface:VariableListenerMethod invoked when the Variable's name is about to change.- Specified by:
variableChangingNamein interfaceVariableListener- Parameters:
var- The Variable whose name is changing.name- The new name for the Variable.- Returns:
trueif the change is allowed.
-
variableChangedName
public void variableChangedName(Variable var)
Description copied from interface:VariableListenerMethod invoked when the Variable's name have changed.- Specified by:
variableChangedNamein interfaceVariableListener- Parameters:
var- The Variable whose name has changed.
-
setValue
public void setValue(double value)
Description copied from interface:HasValueSet the current value.
-
functionValue
public double functionValue()
-
functionMaxValue
public double functionMaxValue()
This method is used to generate toy Mc data sets. It should be overwritten by functions whose maximum value can be provided. If it is not overwriten the maximum value will be evaluated with a mc set of data points.
-
hasAnalyticalNormalization
public boolean hasAnalyticalNormalization(Dependent dep)
To be overwritten if Function provides analytical normalization.
-
evaluateAnalyticalNormalization
public double evaluateAnalyticalNormalization(Dependent dep)
-
value
public double value()
Description copied from interface:HasValueGet the current value.
-
evaluateAnalyticalVariableGradient
public double evaluateAnalyticalVariableGradient(Variable var)
To be overwritten by classes extending Function. This method is used internally by this class to evaluate the derivative with respect to a given Variable.
-
hasAnalyticalVariableGradient
public boolean hasAnalyticalVariableGradient(Variable var)
To be overwritten by classes extending Function. This method is used internally by this class to determine if a function has can provide an analytical gradient with respect to a given Variable.
-
providesGradientWithRespectToVariable
public boolean providesGradientWithRespectToVariable(Variable var)
-
gradient
public double[] gradient()
-
parameterGradient
public double[] parameterGradient()
-
getParameter
public Parameter getParameter(int index)
-
getParameter
public Parameter getParameter(java.lang.String parName)
-
numberOfParameters
public int numberOfParameters()
Description copied from interface:IFunctionNumber of parameters.- Specified by:
numberOfParametersin interfaceIFunction
-
getDependent
public Dependent getDependent(int index)
-
getDependent
public Dependent getDependent(java.lang.String parName)
-
numberOfDependents
public int numberOfDependents()
-
isComposite
public boolean isComposite(Variable var)
-
getNormalizationParameter
public Parameter getNormalizationParameter()
The normalization Parameter for a function is ALWAYS the last one.
-
setNormalizationParamter
public void setNormalizationParamter(Parameter par)
-
addFunctionListener
public void addFunctionListener(FunctionListener listener)
- Specified by:
addFunctionListenerin interfaceFunctionDispatcher
-
removeFunctionListener
public void removeFunctionListener(FunctionListener listener)
- Specified by:
removeFunctionListenerin interfaceFunctionDispatcher
-
variableChangedRange
public void variableChangedRange(Variable var)
Description copied from interface:VariableListenerMethod invoked when the Variable's range have changed.- Specified by:
variableChangedRangein interfaceVariableListener- Parameters:
var- The Variable whose range has changed.
-
normalizationRangeChanged
public void normalizationRangeChanged()
-
isNormalized
public boolean isNormalized()
Description copied from interface:IModelFunctionReturn true if normalization is currently switched on.- Specified by:
isNormalizedin interfaceIModelFunction
-
normalize
public void normalize(boolean normalize)
Description copied from interface:IModelFunctionNormalize by internally adjusting some of the parameters. When normalization is on then integral of the function in the normalization range equals to 1.- Specified by:
normalizein interfaceIModelFunction
-
providesNormalization
public boolean providesNormalization()
- Specified by:
providesNormalizationin interfaceIModelFunction
-
annotation
public IAnnotation annotation()
- Specified by:
annotationin interfaceIFunction
-
codeletString
public java.lang.String codeletString()
Description copied from interface:IFunctionString describing the metatype and implementation of the function. Generic format of the string: codelet:TYPE:LOCATION TYPE part contains only a 'typename' string which is a metatype identifier (used in plugins and catalogues) LOCATION may be: 'file', 'verbatim', or 'catalogue' Detailed description: codelet:typename - no location specified (using 'catalogue') codelet:typename:file:/filename.cpp - a c++ source file codelet:typename:file:/filename.py - a python source file codelet:typename:file:/filename.so - a shared library codelet:typename:catalogue - entry in a catalogue repository codelet:typename:verbatim:cpp \n - c++ source file included verbatim after \n codelet:typename:verbatim:py \n - python source file included verbatim aftern \n Comments: file:/filename is a relative path to $AIDA_FUNCTION_DEFAULT_DIR file://filename is an absolute path Examples: codelet:G:catalogue codelet:userSinus:verbatim:cpp \n { return sin(x); }- Specified by:
codeletStringin interfaceIFunction
-
setCodeletString
public void setCodeletString(java.lang.String str)
-
value
public double value(double[] v)
Description copied from interface:IFunctionScalar value of the function.
-
gradient
public double[] gradient(double[] v)
Description copied from interface:IFunctionGradient of the function. The result is valid only if providesGradient()==true. Otherwise the result is some default (empty) vector.
-
dimension
public int dimension()
Description copied from interface:IFunctionDimensionality of the domain space.
-
indexOfParameter
public int indexOfParameter(java.lang.String parName)
Description copied from interface:IFunctionReturn -1 if parameter not found (name undefined). Leave it because there are use cases - some users prefer to use numbers.- Specified by:
indexOfParameterin interfaceIFunction
-
parameter
public double parameter(java.lang.String parName)
-
parameterNames
public java.lang.String[] parameterNames()
Description copied from interface:IFunctionNames of paramaters. Names should be unique. Case-insensitive for comparison. Case-sensitive for storage and output. All or several names may be left blank "" if the implementation does not want to provide them.- Specified by:
parameterNamesin interfaceIFunction
-
parameters
public double[] parameters()
Description copied from interface:IFunctionRetrieve current vector of parameters.- Specified by:
parametersin interfaceIFunction
-
setParameter
public void setParameter(java.lang.String parName, double parValue) throws java.lang.IllegalArgumentExceptionDescription copied from interface:IFunctionSet parameter's value by name.- Specified by:
setParameterin interfaceIFunction- Parameters:
parName- The name of the parameter.parValue- The new value of the parameter.- Throws:
java.lang.IllegalArgumentException- If name does not correspond to a parameter.
-
setParameters
public void setParameters(double[] pars) throws java.lang.IllegalArgumentExceptionDescription copied from interface:IFunctionSet new vector of parameters.- Specified by:
setParametersin interfaceIFunction- Throws:
java.lang.IllegalArgumentException
-
setTitle
public void setTitle(java.lang.String title) throws java.lang.IllegalArgumentExceptionDescription copied from interface:IFunctionSet the histogram title.
-
title
public java.lang.String title()
Description copied from interface:IFunctionGet the Function's title.
-
variableName
public java.lang.String variableName(int index)
Description copied from interface:IFunctionGet the symbolic name of i-th variable.- Specified by:
variableNamein interfaceIFunction
-
variableNames
public java.lang.String[] variableNames()
Description copied from interface:IFunctionGet all the names in a vector.- Specified by:
variableNamesin interfaceIFunction
-
functionValue
public double functionValue(double[] v)
-
excludeNormalizationAll
public void excludeNormalizationAll()
Description copied from interface:IModelFunctionSet empty range in all axes.- Specified by:
excludeNormalizationAllin interfaceIModelFunction
-
includeNormalizationAll
public void includeNormalizationAll()
Description copied from interface:IModelFunctionSet full range in all axes.- Specified by:
includeNormalizationAllin interfaceIModelFunction
-
normalizationRange
public IRangeSet normalizationRange(int i)
Description copied from interface:IModelFunctionSet the normalization range from -inf to +inf in the i-th axis (dimension). Full range is the default if not set otherwise. It is still possible to evaluate function outside of the normalization range. PENDING: no methods to retrieve current range!- Specified by:
normalizationRangein interfaceIModelFunction
-
parameterGradient
public double[] parameterGradient(double[] v)
Description copied from interface:IModelFunctionCompute gradient with respect to parameters.- Specified by:
parameterGradientin interfaceIModelFunction
-
isEqual
public boolean isEqual(IFunction iFunction)
Description copied from interface:IFunctionCompare if functions are the same. PENDING: define exactly what it means ;)
-
providesGradient
public boolean providesGradient()
Description copied from interface:IFunctionDetermine whether function is able to compute gradient.- Specified by:
providesGradientin interfaceIFunction
-
providesParameterGradient
public boolean providesParameterGradient()
Description copied from interface:IModelFunctionReturn true if provides parameter gradient.- Specified by:
providesParameterGradientin interfaceIModelFunction
-
-
DMelt 3.0 © DataMelt by jWork.ORG