All Downloads are FREE. Search and download functionalities are using the official Maven repository.

gov.sandia.cognition.statistics.bayesian.conjugate.AbstractConjugatePriorBayesianEstimator Maven / Gradle / Ivy

There is a newer version: 4.0.1
Show newest version
/*
 * File:                AbstractConjugatePriorBayesianEstimator.java
 * Authors:             Kevin R. Dixon
 * Company:             Sandia National Laboratories
 * Project:             Cognitive Foundry
 * 
 * Copyright Nov 16, 2009, 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.conjugate;

import gov.sandia.cognition.learning.algorithm.AbstractBatchAndIncrementalLearner;
import gov.sandia.cognition.statistics.ClosedFormDistribution;
import gov.sandia.cognition.statistics.bayesian.BayesianParameter;
import gov.sandia.cognition.util.ObjectUtil;

/**
 * Partial implementation of ConjugatePriorBayesianEstimator that contains a initial belief
 * (prior) distribution function.
 * @param 
 * Observations from the ConditionalType that are used to estimate the
 * parameters of the distribution.
 * @param 
 * Type of Distribution that represents uncertainty in the parameters.
 * @param 
 * Type of parameter estimated by this algorithm, which is used to
 * parameterize the conditional distribution.
 * @param 
 * Type of conditional distribution that generates observations for this
 * relationship.
 * @author Kevin R. Dixon
 * @since 3.0
 */
public abstract class AbstractConjugatePriorBayesianEstimator,BeliefType extends ClosedFormDistribution>
    extends AbstractBatchAndIncrementalLearner
    implements ConjugatePriorBayesianEstimator
{

    /**
     * Bayesian hyperparameter relationship between the conditional
     * distribution and the conjugate prior distribution.
     */
    protected BayesianParameter parameter;

    /** 
     * Creates a new instance of AbstractConjugatePriorBayesianEstimator
     * @param parameter
     * Bayesian hyperparameter relationship between the conditional
     * distribution and the conjugate prior distribution.
     */
    public AbstractConjugatePriorBayesianEstimator(
        BayesianParameter parameter )
    {
        super();
        this.setParameter(parameter);
    }

    @Override
    public AbstractConjugatePriorBayesianEstimator clone()
    {
        @SuppressWarnings("unchecked")
        AbstractConjugatePriorBayesianEstimator clone =
            (AbstractConjugatePriorBayesianEstimator) super.clone();
        clone.setParameter( ObjectUtil.cloneSafe( this.getParameter() ) );
        return clone;
    }

    public BeliefType createInitialLearnedObject()
    {
        return ObjectUtil.cloneSmart(this.getInitialBelief());
    }

    public ConditionalType createConditionalDistribution(
        ParameterType parameter)
    {
        this.parameter.setValue(parameter);
        return ObjectUtil.cloneSafe(this.parameter.getConditionalDistribution());
    }

    /**
     * Getter for initialBelief.
     * @return
     * Initial belief distribution of the parameters.
     */
    public BeliefType getInitialBelief()
    {
        return this.parameter.getParameterPrior();
    }

    public BayesianParameter getParameter()
    {
        return this.parameter;
    }

    /**
     * Setter for parameter
     * @param parameter
     * Bayesian hyperparameter relationship between the conditional
     * distribution and the conjugate prior distribution.
     */
    protected void setParameter(
        BayesianParameter parameter)
    {
        this.parameter = parameter;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy