commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gilles Sadowski <gil...@harfang.homelinux.org>
Subject Re: [math] QR decomposition in HarmonicFitter
Date Sat, 11 Aug 2012 23:29:20 GMT
Hi.

> 
> I am trying to set up a harmonic fitter to determine periodicity of a data
> set. My code:
> import org.apache.commons.math3.optimization.fitting.HarmonicFitter;
> import org.apache.commons.math3.optimization.fitting.WeightedObservedPoint;
> import
> org.apache.commons.math3.optimization.general.LevenbergMarquardtOptimizer;
> 
> 
> public class FFT {
> 	public static void main(String[] args){
> 		double[] real =
> {0,1,2,3,2,1,0,-1,-2,-3,-2,-1,0,1,2,3,2,1,0,-1,-2,-3,-2,-1,0,1,2,3,2,1,0};
> 		WeightedObservedPoint[] points = new WeightedObservedPoint
> [real.length];
> 		HarmonicFitter fitter = new HarmonicFitter(new
> LevenbergMarquardtOptimizer());
> 		for(int i = 0; i < real.length; i++){
> 			points[i] = new WeightedObservedPoint(1,i,real[i]);
> 			fitter.addObservedPoint(new WeightedObservedPoint
> (1,i,real[i]));
> 		}
> 		HarmonicFitter.ParameterGuesser guesser = new
> HarmonicFitter.ParameterGuesser(points);
> 		double[] guess = fitter.fit(guesser.guess());
> 		for(double x:guess){
> 			System.out.println(x);
> 		}
> 	}
> }
> 
> and the error:
> Exception in thread "main"
> org.apache.commons.math3.exception.ConvergenceException: illegal state:
> unable to perform Q.R decomposition on the 31x3 jacobian matrix
> [...]

This seems to be caused by the "degenerate" input (a slight change in the
values and the fit proceeds fine). In order to investigate where the problem
occurs, it might be worth opening a report on the Commons Math bug tracking
system. [Unfortunately the web site is currently down...]


Regards,
Gilles

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message