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

jasima.core.random.continuous.DblTDist Maven / Gradle / Ivy

/*******************************************************************************
 * This file is part of jasima, v1.3, the Java simulator for manufacturing and 
 * logistics.
 *  
 * Copyright (c) 2015 		jasima solutions UG
 * Copyright (c) 2010-2015 Torsten Hildebrandt and jasima contributors
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see .
 *******************************************************************************/
package jasima.core.random.continuous;

import jasima.core.util.Util;

import org.apache.commons.math3.distribution.RealDistribution;
import org.apache.commons.math3.distribution.TDistribution;
import org.apache.commons.math3.exception.NotStrictlyPositiveException;

/**
 * Implements a stream of numbers following a Student's
 * t-distribution. The distribution has a single shape parameter:
 * {@code degreesOfFreedom}.
 * 
 * @author Torsten Hildebrandt
 * @version 
 *          "$Id: DblTDist.java 753 2015-07-27 15:29:49Z [email protected] $"
 * 
 * @see Student's
 *      t-distribution (Wikipedia)
 * @see Student
 *      's t-Distribution (MathWorld)
 */
public class DblTDist extends DblDistribution {

	private static final long serialVersionUID = -3355042798681194054L;

	private TDistribution dist;

	public DblTDist() {
		this(1.0);
	}

	public DblTDist(double degreesOfFreedom) {
		super();
		setDistribution(new TDistribution(degreesOfFreedom));
	}

	@Override
	protected void setDistribution(RealDistribution distribution) {
		dist = (TDistribution) distribution;
		super.setDistribution(distribution);
	}

	@Override
	public String toString() {
		return String.format(Util.DEF_LOCALE, "DblTDist(degreesOfFreedom=%f)",
				getDegreesOfFreedom());
	}

	public double getDegreesOfFreedom() {
		return dist.getDegreesOfFreedom();
	}

	/**
	 * Sets the degrees of freedom for this distribution.
	 * 
	 * @param degreesOfFreedom
	 *            The degrees of freedom to use.
	 * @throws NotStrictlyPositiveException
	 *             If the parameter value was {@code <=0.0}.
	 */
	public void setDegreesOfFreedom(double degreesOfFreedom)
			throws NotStrictlyPositiveException {
		setDistribution(new TDistribution(degreesOfFreedom));
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy