//
// OpenForecast - open source, general-purpose forecasting package.
// Copyright (C) 2002-2011 Steven R. Gould
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library 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
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
package net.sourceforge.openforecast.tests;
import net.sourceforge.openforecast.ForecastingModel;
import net.sourceforge.openforecast.DataPoint;
import net.sourceforge.openforecast.DataSet;
import net.sourceforge.openforecast.Observation;
import net.sourceforge.openforecast.models.SimpleExponentialSmoothingModel;
/**
* Tests the implementation of the Simple Exponential Smoothing forecasting
* model.
* @author Steven R. Gould
* @since 0.4
*/
public class SimpleExponentialSmoothingTest extends OpenForecastTestCase
{
/**
* The amount of error in the forecast values where the forecast is
* considered "correct" by the test.
*/
private static double TOLERANCE = 0.005;
/**
* The amount of error/tolerance in the Mean Squared Error where the
* forecast is still considered "correct" by the test.
*/
private static double MSE_TOLERANCE = 0.1;
/**
* Constructor required by the JUnit framework.
*/
public SimpleExponentialSmoothingTest( String name )
{
super(name);
}
/**
* A simple exponential smoothing test where the observed data is
* constant. This should result in the same constant forecast for
* any value of the smoothing constant.
*/
public void testConstantSimpleExponentialSmoothing()
{
final int NUMBER_OF_OBSERVATIONS = 25;
// Set up some constant observed values
DataSet observedData = new DataSet();
DataPoint dp;
for ( int t=0; tEngineering Statistics Handbook, 6.4.3.1 Single Exponential Smoothing
*/
public void testSimpleExponentialSmoothing()
{
DataSet observedData = new DataSet();
DataPoint dp;
double[] observations
= { 71.0, 70.0, 69.0, 68.0, 64.0, 65.0,
72.0, 78.0, 75.0, 75.0, 75.0, 70.0 };
for ( int t=0; tExample 13.5.1. The sales of musical instruments by a local
* music store for the past 10 months are as follows: 74, 69, 80, 91,
* 76, 83, 79, 87, 89, and 92.
* @see net.sourceforge.openforecast.models.SimpleExponentialSmoothingModel
*/
public void testMusicStoreExample()
{
DataSet observedData = new DataSet();
DataPoint dp;
double[] observations
= { 74.0, 69.0, 80.0, 91.0, 76.0,
83.0, 79.0, 87.0, 89.0, 92.0 };
for ( int t=0; t
Ads help maintain this website.