FreeHEP API
Version current

hep.aida.ref.pdf
Class Function

java.lang.Object
  extended byhep.aida.ref.pdf.Variable
      extended byhep.aida.ref.pdf.Function
All Implemented Interfaces:
FunctionDispatcher, HasName, HasUnits, HasValue, hep.aida.IFunction, hep.aida.IModelFunction, VariableListener
Direct Known Subclasses:
Exponential, Gaussian, IFunctionWrapper, NonParametricPdf, Product, Step, Sum

public class Function
extends Variable
implements hep.aida.IModelFunction, VariableListener, FunctionDispatcher

Base function. Any function should extend this class.

Author:
The FreeHEP team @ SLAC.
Source Code:
Function.java

Field Summary
 
Fields inherited from class hep.aida.ref.pdf.Variable
DEPENDENT, FUNCTION, PARAMETER
 
Constructor Summary
Function(String name)
           
 
Method Summary
 void addFunctionListener(FunctionListener listener)
           
 void addVariable(Variable v)
          Variables Management.
 void addVariables(VariableList list)
           
 hep.aida.IAnnotation annotation()
           
 String codeletString()
           
 int dimension()
           
 double evaluateAnalyticalNormalization(Dependent dep)
           
 double evaluateAnalyticalVariableGradient(Variable var)
          To be overwritten by classes extending Function.
 void excludeNormalizationAll()
           
 double functionMaxValue()
          This method is used to generate toy Mc data sets.
 double functionValue()
           
 double functionValue(double[] v)
           
 Dependent getDependent(int index)
           
 Dependent getDependent(String parName)
           
 Parameter getNormalizationParameter()
          The normalization Parameter for a function is ALWAYS the last one.
 Parameter getParameter(int index)
           
 Parameter getParameter(String parName)
           
 double[] gradient()
           
 double[] gradient(double[] v)
           
 boolean hasAnalyticalNormalization(Dependent dep)
          To be overwritten if Function provides analytical normalization.
 boolean hasAnalyticalVariableGradient(Variable var)
          To be overwritten by classes extending Function.
protected  boolean hasDependent(Dependent dep)
           
protected  boolean hasParameter(Parameter par)
           
protected  boolean hasVariable(Variable var)
           
 void includeNormalizationAll()
           
 int indexOfParameter(String parName)
           
 boolean isComposite(Variable var)
           
 boolean isEqual(hep.aida.IFunction iFunction)
           
 boolean isNormalized()
           
protected  double maxValue()
           
 String normalizationParameter()
           
 hep.aida.IRangeSet normalizationRange(int i)
           
 void normalizationRangeChanged()
           
 void normalize(boolean normalize)
           
protected  void notifyFunctionChanged(FunctionChangedEvent event)
           
 int numberOfDependents()
           
 int numberOfParameters()
           
 double parameter(String parName)
           
 double[] parameterGradient()
           
 double[] parameterGradient(double[] v)
           
 String[] parameterNames()
           
 double[] parameters()
           
 boolean providesGradient()
           
 boolean providesGradientWithRespectToVariable(Variable var)
           
 boolean providesNormalization()
           
 boolean providesParameterGradient()
           
 void removeFunctionListener(FunctionListener listener)
           
 void setCodeletString(String str)
           
 void setNormalizationParamter(Parameter par)
           
 void setParameter(String parName, double parValue)
           
 void setParameters(double[] pars)
           
 void setTitle(String title)
           
 void setValue(double value)
          Set the current value.
protected  void setVariableValue(double value)
           
 String title()
           
protected  void updateNormalization()
           
 double value()
          Get the current value.
 double value(double[] v)
           
 void variableChanged(Variable var)
          This method is invoked when a variable in the function has changed its value.
 void variableChangedName(Variable var)
          Method invoked when the Variable's name have changed.
 void variableChangedRange(Variable var)
          Method invoked when the Variable's range have changed.
 void variableChangedUnits(Variable var)
          Method invoked when the Variable's Units have changed.
 void variableChangedValue(Variable var)
          Method invoked when the Variable's value have changed.
 boolean variableChangingName(Variable var, String name)
          Method invoked when the Variable's name is about to change.
 boolean variableChangingUnits(Variable var, Units units)
          Method invoked when the Variable's Units are about to change.
 boolean variableChangingValue(Variable var, double value)
          Method invoked when the Variable's value is about to change.
 String variableName(int index)
           
 String[] variableNames()
           
 
Methods inherited from class hep.aida.ref.pdf.Variable
addVariableListener, name, removeVariableListener, setName, setUnits, type, units
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Function

public Function(String name)
Method Detail

addVariable

public void addVariable(Variable v)
Variables Management.


addVariables

public void addVariables(VariableList list)

hasDependent

protected boolean hasDependent(Dependent dep)

hasParameter

protected boolean hasParameter(Parameter par)

hasVariable

protected boolean hasVariable(Variable var)

variableChangingUnits

public boolean variableChangingUnits(Variable var,
                                     Units units)
Description copied from interface: VariableListener
Method invoked when the Variable's Units are about to change.

Specified by:
variableChangingUnits in interface VariableListener
Parameters:
var - The Variable whose Units are changing.
units - The new Units for the Variable.
Returns:
true if the change is allowed.

variableChangedUnits

public void variableChangedUnits(Variable var)
Description copied from interface: VariableListener
Method invoked when the Variable's Units have changed.

Specified by:
variableChangedUnits in interface VariableListener
Parameters:
var - The Variable whose Units have changed.

variableChangingValue

public boolean variableChangingValue(Variable var,
                                     double value)
Description copied from interface: VariableListener
Method invoked when the Variable's value is about to change.

Specified by:
variableChangingValue in interface VariableListener
Parameters:
var - The Variable whose value is changing.
value - The new value for the Variable.
Returns:
true if the change is allowed.

normalizationParameter

public String normalizationParameter()
Specified by:
normalizationParameter in interface hep.aida.IFunction

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: VariableListener
Method invoked when the Variable's value have changed.

Specified by:
variableChangedValue in interface VariableListener
Parameters:
var - The Variable whose value have changed.

variableChangingName

public boolean variableChangingName(Variable var,
                                    String name)
Description copied from interface: VariableListener
Method invoked when the Variable's name is about to change.

Specified by:
variableChangingName in interface VariableListener
Parameters:
var - The Variable whose name is changing.
name - The new name for the Variable.
Returns:
true if the change is allowed.

variableChangedName

public void variableChangedName(Variable var)
Description copied from interface: VariableListener
Method invoked when the Variable's name have changed.

Specified by:
variableChangedName in interface VariableListener
Parameters:
var - The Variable whose name has changed.

setValue

public void setValue(double value)
Description copied from interface: HasValue
Set the current value.

Specified by:
setValue in interface HasValue
Overrides:
setValue in class Variable

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.


updateNormalization

protected void updateNormalization()

hasAnalyticalNormalization

public boolean hasAnalyticalNormalization(Dependent dep)
To be overwritten if Function provides analytical normalization.


evaluateAnalyticalNormalization

public double evaluateAnalyticalNormalization(Dependent dep)

maxValue

protected double maxValue()

value

public double value()
Description copied from interface: HasValue
Get the current value.

Specified by:
value in interface HasValue
Specified by:
value in class Variable

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(String parName)

numberOfParameters

public int numberOfParameters()
Specified by:
numberOfParameters in interface hep.aida.IFunction

getDependent

public Dependent getDependent(int index)

getDependent

public Dependent getDependent(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:
addFunctionListener in interface FunctionDispatcher

removeFunctionListener

public void removeFunctionListener(FunctionListener listener)
Specified by:
removeFunctionListener in interface FunctionDispatcher

notifyFunctionChanged

protected void notifyFunctionChanged(FunctionChangedEvent event)

variableChangedRange

public void variableChangedRange(Variable var)
Description copied from interface: VariableListener
Method invoked when the Variable's range have changed.

Specified by:
variableChangedRange in interface VariableListener
Parameters:
var - The Variable whose range has changed.

normalizationRangeChanged

public void normalizationRangeChanged()

isNormalized

public boolean isNormalized()
Specified by:
isNormalized in interface hep.aida.IModelFunction

normalize

public void normalize(boolean normalize)
Specified by:
normalize in interface hep.aida.IModelFunction

providesNormalization

public boolean providesNormalization()
Specified by:
providesNormalization in interface hep.aida.IModelFunction

annotation

public hep.aida.IAnnotation annotation()
Specified by:
annotation in interface hep.aida.IFunction

codeletString

public String codeletString()
Specified by:
codeletString in interface hep.aida.IFunction

setCodeletString

public void setCodeletString(String str)

value

public double value(double[] v)
Specified by:
value in interface hep.aida.IFunction

gradient

public double[] gradient(double[] v)
Specified by:
gradient in interface hep.aida.IFunction

dimension

public int dimension()
Specified by:
dimension in interface hep.aida.IFunction

indexOfParameter

public int indexOfParameter(String parName)
Specified by:
indexOfParameter in interface hep.aida.IFunction

parameter

public double parameter(String parName)
Specified by:
parameter in interface hep.aida.IFunction

parameterNames

public String[] parameterNames()
Specified by:
parameterNames in interface hep.aida.IFunction

parameters

public double[] parameters()
Specified by:
parameters in interface hep.aida.IFunction

setParameter

public void setParameter(String parName,
                         double parValue)
                  throws IllegalArgumentException
Specified by:
setParameter in interface hep.aida.IFunction
Throws:
IllegalArgumentException

setParameters

public void setParameters(double[] pars)
                   throws IllegalArgumentException
Specified by:
setParameters in interface hep.aida.IFunction
Throws:
IllegalArgumentException

setTitle

public void setTitle(String title)
              throws IllegalArgumentException
Specified by:
setTitle in interface hep.aida.IFunction
Throws:
IllegalArgumentException

title

public String title()
Specified by:
title in interface hep.aida.IFunction

variableName

public String variableName(int index)
Specified by:
variableName in interface hep.aida.IFunction

variableNames

public String[] variableNames()
Specified by:
variableNames in interface hep.aida.IFunction

functionValue

public double functionValue(double[] v)

excludeNormalizationAll

public void excludeNormalizationAll()
Specified by:
excludeNormalizationAll in interface hep.aida.IModelFunction

includeNormalizationAll

public void includeNormalizationAll()
Specified by:
includeNormalizationAll in interface hep.aida.IModelFunction

normalizationRange

public hep.aida.IRangeSet normalizationRange(int i)
Specified by:
normalizationRange in interface hep.aida.IModelFunction

parameterGradient

public double[] parameterGradient(double[] v)
Specified by:
parameterGradient in interface hep.aida.IModelFunction

isEqual

public boolean isEqual(hep.aida.IFunction iFunction)
Specified by:
isEqual in interface hep.aida.IFunction

providesGradient

public boolean providesGradient()
Specified by:
providesGradient in interface hep.aida.IFunction

providesParameterGradient

public boolean providesParameterGradient()
Specified by:
providesParameterGradient in interface hep.aida.IModelFunction

setVariableValue

protected void setVariableValue(double value)
Specified by:
setVariableValue in class Variable

FreeHEP API
Version current

Copyright © 2000-2004 FreeHEP, All Rights Reserved.