fenomen - 2012-01-03


I tried to run the application which I found here: http://www.stevengould.org/portfolio/independent/ofc-ug/x90.html
But I'm afraid it doesn't seem to work. I get every time a NullPointerException although I'm adding Obervations / Datapoints to a DataSet. Have a look at my Code:

package openforecast;
import java.util.Iterator;
import net.sourceforge.openforecast.DataPoint;
import net.sourceforge.openforecast.DataSet;
import net.sourceforge.openforecast.Observation;
import net.sourceforge.openforecast.models.MovingAverageModel;
public class Test {
    public Test() {
        // Create DataPoint/Observation for quarter 4
        DataPoint fcDataPointQ4 = new Observation(0.0);
        fcDataPointQ4.setIndependentValue("quarter", 4);
        // Create Observation/DataPoint for quarter 5
        DataPoint fcDataPointQ5 = new Observation(0.0);
        fcDataPointQ5.setIndependentValue("quarter", 5);
        // Create forecast data set and add these DataPoints
        DataSet fcDataSet = new DataSet();
        MovingAverageModel model = new MovingAverageModel();
        Iterator<DataPoint> it = fcDataSet.iterator();
        while (it.hasNext()) {
            DataPoint dp = (DataPoint) it.next();
            double forecastValue = dp.getDependentValue();
            // Do something with the forecast value, e.g.
            System.out.println("Hallo " + forecastValue);
    public static void main(String[] argv) {
        new Test();

That's the output of the console:

Exception in thread "main" java.lang.NullPointerException
at net.sourceforge.openforecast.models.WeightedMovingAverageModel.getNumberOfPeriods(WeightedMovingAverageModel.java:222)
at net.sourceforge.openforecast.models.MovingAverageModel.init(MovingAverageModel.java:138)
at openforecast.Test.<init>(Test.java:29)
at openforecast.Test.main(Test.java:46)

The Exception is thrown at this line:

Anybody can help what I am doing wrong?

Thank you for your answer!