gov.sandia.cognition.statistics.bayesian.AbstractBayesianParameter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gov-sandia-cognition-learning-core Show documentation
Show all versions of gov-sandia-cognition-learning-core Show documentation
Algorithms and components for machine learning and statistics.
The newest version!
/*
* File: AbstractBayesianParameter.java
* Authors: Kevin R. Dixon
* Company: Sandia National Laboratories
* Project: Cognitive Foundry
*
* Copyright Apr 8, 2010, Sandia Corporation.
* Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive
* license for use of this work by or on behalf of the U.S. Government.
* Export of this program may require a license from the United States
* Government. See CopyrightHistory.txt for complete details.
*
*/
package gov.sandia.cognition.statistics.bayesian;
import gov.sandia.cognition.statistics.ClosedFormDistribution;
import gov.sandia.cognition.statistics.Distribution;
import gov.sandia.cognition.util.AbstractNamed;
import gov.sandia.cognition.util.ObjectUtil;
import java.util.Random;
/**
* Partial implementation of BayesianParameter
* @param
* Type of parameter that changes the behavior of the conditional distribution.
* @param
* Type of parameterized distribution that generates observations.
* @param
* Assumed underlying distribution of parameters of the conditional distribution.
* @author Kevin R. Dixon
* @since 3.0
*/
public abstract class AbstractBayesianParameter,PriorType extends Distribution>
extends AbstractNamed
implements BayesianParameter
{
/**
* Distribution from which to pull the parameters.
*/
protected ConditionalType conditionalDistribution;
/**
* Distribution of values that the parameter is assumed to take.
*/
private PriorType parameterPrior;
/**
* Creates a new instance of AbstractBayesianParameter
*/
public AbstractBayesianParameter()
{
this( null, null, null );
}
/**
* Creates a new instance of AbstractBayesianParameter
* @param conditionalDistribution
* Distribution from which to pull the parameters.
* @param name The parameter's name
* @param parameterPrior
* Distribution of values that the parameter is assumed to take.
*/
public AbstractBayesianParameter(
ConditionalType conditionalDistribution,
String name,
PriorType parameterPrior)
{
super( name );
this.setConditionalDistribution(conditionalDistribution);
this.setParameterPrior(parameterPrior);
}
@Override
public AbstractNamed clone()
{
@SuppressWarnings("unchecked")
AbstractBayesianParameter clone =
(AbstractBayesianParameter) super.clone();
clone.setConditionalDistribution(
ObjectUtil.cloneSafe( this.getConditionalDistribution() ) );
clone.setParameterPrior( ObjectUtil.cloneSafe( this.getParameterPrior() ) );
return clone;
}
/**
* Getter for conditionalDistribution
* @return
* Distribution from which to pull the parameters.
*/
public ConditionalType getConditionalDistribution()
{
return this.conditionalDistribution;
}
/**
* Setter for conditionalDistribution
* @param conditionalDistribution
* Distribution from which to pull the parameters.
*/
protected void setConditionalDistribution(
ConditionalType conditionalDistribution)
{
this.conditionalDistribution = conditionalDistribution;
}
/**
* Getter for parameterPrior
* @return
* Distribution of values that the parameter is assumed to take.
*/
public PriorType getParameterPrior()
{
return this.parameterPrior;
}
/**
* Setter for parameterPrior
* @param parameterPrior
* Distribution of values that the parameter is assumed to take.
*/
protected void setParameterPrior(
PriorType parameterPrior)
{
this.parameterPrior = parameterPrior;
}
public void updateConditionalDistribution(
Random random)
{
ParameterType parameter = this.parameterPrior.sample(random);
this.setValue(parameter);
}
}