Parameters
Class Parameters

java.lang.Object
  extended by Parameters.Parameters
All Implemented Interfaces:
java.io.Serializable, java.lang.Iterable<Parameter>

public class Parameters
extends java.lang.Object
implements java.lang.Iterable<Parameter>, java.io.Serializable

Represents a set of parameters

Version:
1.0
See Also:
Serialized Form

Nested Class Summary
 class Parameters.ParameterException
          Exception related to the parameters
 
Constructor Summary
Parameters()
          Creates an empty set of parameters
Parameters(java.util.ArrayList<Parameter> params)
          Creates a set of parameters containing the given parameters
 
Method Summary
 void addParameter(Parameter p)
          Add a parameter
 void addParameters(Parameters pp)
          Adds the parameters from another set of parameters
 void calculated()
          Resets the testfor whether probability matrices need to be recalculalated.
 Parameters clone()
           
static Parameters fromFile(java.io.File f)
          Reads parameters from a file.
 Parameter getParam(java.lang.String name)
          Gets the parameter with the given name
 double getValue(java.lang.String name)
          Gets the value of a parameter
 java.util.HashMap<java.lang.String,java.lang.Double> getValues()
          Gets a map from parameter name to the value of that parameter
 boolean hasParam(java.lang.String name)
          Checks whether there is a parameter with the given name
 java.util.Iterator<Parameter> iterator()
           
 int numberEstimate()
          Gets the number of parameters to be estimated
 boolean recalculateMatrix()
          Tests whether any parameters that would require recalculation of the probability matrices have been changed since the last call to calculated()
 void setValue(Parameter p, double v)
          Sets the value of a parameter
 void toFile(java.io.File f)
          Writes the parameter values to a file.
 void toFile(java.io.File f, double like)
          Writes the parameter values to a file and writes a line labeled likelihood and which gives the likelihood given as input.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Parameters

public Parameters()
Creates an empty set of parameters


Parameters

public Parameters(java.util.ArrayList<Parameter> params)
Creates a set of parameters containing the given parameters

Parameters:
params - A list of parameters
Method Detail

clone

public Parameters clone()
Overrides:
clone in class java.lang.Object

addParameter

public void addParameter(Parameter p)
Add a parameter

Parameters:
p - The parameter

addParameters

public void addParameters(Parameters pp)
Adds the parameters from another set of parameters

Parameters:
pp - The other set of parameters

recalculateMatrix

public boolean recalculateMatrix()
Tests whether any parameters that would require recalculation of the probability matrices have been changed since the last call to calculated()

Returns:
Whether the probability matrices need to be recalculated.

calculated

public void calculated()
Resets the testfor whether probability matrices need to be recalculalated. Should be called just after they have been recalculated.


setValue

public void setValue(Parameter p,
                     double v)
Sets the value of a parameter

Parameters:
p - The parameter
v - The value

getValue

public double getValue(java.lang.String name)
                throws Parameters.ParameterException
Gets the value of a parameter

Parameters:
name - The parameters name
Returns:
The value of that parameter.
Throws:
Parameters.ParameterException - Thrown if there is no parameter with that name

getParam

public Parameter getParam(java.lang.String name)
                   throws Parameters.ParameterException
Gets the parameter with the given name

Parameters:
name - The name of the parameter
Returns:
The parameter
Throws:
Parameters.ParameterException - Thrown if there is no parameter with that name

hasParam

public boolean hasParam(java.lang.String name)
Checks whether there is a parameter with the given name

Parameters:
name - The name of the parameter
Returns:
Whether there is a parameter with that name

getValues

public java.util.HashMap<java.lang.String,java.lang.Double> getValues()
Gets a map from parameter name to the value of that parameter

Returns:
Map from parameter name to parameter value

numberEstimate

public int numberEstimate()
Gets the number of parameters to be estimated

Returns:
The number of parameters to be estimated

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

iterator

public java.util.Iterator<Parameter> iterator()
Specified by:
iterator in interface java.lang.Iterable<Parameter>

toFile

public void toFile(java.io.File f)
            throws OutputException
Writes the parameter values to a file. Each parameter uses one line and the format of that line is as described at Parameter.fromString(java.lang.String)

Parameters:
f - File to write the parameters to
Throws:
OutputException - Thrown if an error occurs writing the file

toFile

public void toFile(java.io.File f,
                   double like)
            throws OutputException
Writes the parameter values to a file and writes a line labeled likelihood and which gives the likelihood given as input. Each parameter uses one line and the format of that line is as described at Parameter.fromString(java.lang.String)

Parameters:
f - File to write the parameters to
like - The likelihood value
Throws:
OutputException - Thrown if an error occurs writing the file

fromFile

public static Parameters fromFile(java.io.File f)
                           throws InputException
Reads parameters from a file. Each parameter is a single line and is described at Parameter.fromString(java.lang.String).

Parameters:
f - The input file
Returns:
A Parameters instance
Throws:
InputException - If there is an input error