de.jstacs.classifiers.differentiableSequenceScoreBased.logPrior
Class SeparateLaplaceLogPrior

java.lang.Object
  extended by de.jstacs.algorithms.optimization.DifferentiableFunction
      extended by de.jstacs.classifiers.differentiableSequenceScoreBased.logPrior.LogPrior
          extended by de.jstacs.classifiers.differentiableSequenceScoreBased.logPrior.SeparateLogPrior
              extended by de.jstacs.classifiers.differentiableSequenceScoreBased.logPrior.SeparateLaplaceLogPrior
All Implemented Interfaces:
Function, Storable, Cloneable

public class SeparateLaplaceLogPrior
extends SeparateLogPrior

Class for a LogPrior that defines a Laplace prior on the parameters of a set of DifferentiableStatisticalModels and a set of class parameters. The scale hyperparameters of the Laplace prior are determined from a set of class-specific base variances and the class variances, respectively. The formula to determine the shape hyperparameter b[i] for a parameter i from a variance v[i] is
b[i] = Math.sqrt(v[i]/2).
The variances v[i] for a parameter i of a DifferentiableStatisticalModel fun[j] are determined from the base variance v[j] as
v[i] = v[j]*funs[j].getSizeOfEventSpaceForRandomVariablesOfParameter(j) .
The mean parameters are set to 0 for the parameters of the DifferentiableStatisticalModels and to the user-specified means for the class parameters.

Author:
Jan Grau, Jens Keilwagen

Field Summary
 
Fields inherited from class de.jstacs.classifiers.differentiableSequenceScoreBased.logPrior.SeparateLogPrior
classMus, classVars, freeParameters, funs, vars
 
Fields inherited from class de.jstacs.classifiers.differentiableSequenceScoreBased.logPrior.LogPrior
UNKNOWN
 
Constructor Summary
SeparateLaplaceLogPrior(double[] vars, double[] classVars, double[] classMus)
          Creates a new SeparateLaplaceLogPrior from a set of base variances vars, a set of class variances classVars and a set of class means classMus.
SeparateLaplaceLogPrior(StringBuffer xml)
          The standard constructor for the interface Storable.
 
Method Summary
 void addGradientFor(double[] params, double[] vector)
          Adds the gradient of the log-prior using the current parameters to a given vector.
 double evaluateFunction(double[] x)
          Evaluates the function at a certain vector (in mathematical sense) x.
 int getDimensionOfScope()
          Returns the dimension of the scope of the Function.
 String getInstanceName()
          Returns a short instance name.
protected  void unset()
          Resets all internally pre-computed values, e.g.
 
Methods inherited from class de.jstacs.classifiers.differentiableSequenceScoreBased.logPrior.SeparateLogPrior
getNewInstance, set, toXML
 
Methods inherited from class de.jstacs.classifiers.differentiableSequenceScoreBased.logPrior.LogPrior
evaluateGradientOfFunction
 
Methods inherited from class de.jstacs.algorithms.optimization.DifferentiableFunction
findOneDimensionalMin
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SeparateLaplaceLogPrior

public SeparateLaplaceLogPrior(double[] vars,
                               double[] classVars,
                               double[] classMus)
Creates a new SeparateLaplaceLogPrior from a set of base variances vars, a set of class variances classVars and a set of class means classMus.

Parameters:
vars - the base variances for each class
classVars - the class variances
classMus - the class means
See Also:
SeparateLogPrior.SeparateLogPrior(double[], double[], double[])

SeparateLaplaceLogPrior

public SeparateLaplaceLogPrior(StringBuffer xml)
                        throws NonParsableException
The standard constructor for the interface Storable. Creates a new SeparateLaplaceLogPrior out of its XML representation.

Parameters:
xml - the XML representation as StringBuffer
Throws:
NonParsableException - if the SeparateLaplaceLogPrior could not be reconstructed out of the XML representation (the StringBuffer could not be parsed)
See Also:
SeparateLogPrior.SeparateLogPrior(StringBuffer), Storable
Method Detail

unset

protected void unset()
Description copied from class: SeparateLogPrior
Resets all internally pre-computed values, e.g. the hyperparameters for each parameter.

Specified by:
unset in class SeparateLogPrior

addGradientFor

public void addGradientFor(double[] params,
                           double[] vector)
Description copied from class: LogPrior
Adds the gradient of the log-prior using the current parameters to a given vector.

Specified by:
addGradientFor in class LogPrior
Parameters:
params - the parameters
vector - the vector

evaluateFunction

public double evaluateFunction(double[] x)
                        throws DimensionException,
                               EvaluationException
Description copied from interface: Function
Evaluates the function at a certain vector (in mathematical sense) x.

Parameters:
x - the current vector
Returns:
the evaluation of the function
Throws:
DimensionException - if dim(x) != n, with $f: \mathbb{R}^n \to \mathbb{R}$
EvaluationException - if there was something wrong during the evaluation of the function

getDimensionOfScope

public int getDimensionOfScope()
Description copied from interface: Function
Returns the dimension of the scope of the Function.

Returns:
the dimension of the scope: n with $f: \mathbb{R}^n \to \mathbb{R}$

getInstanceName

public String getInstanceName()
Description copied from class: LogPrior
Returns a short instance name.

Specified by:
getInstanceName in class LogPrior
Returns:
a short instance name