Quantcast
Channel: Math.NET Numerics
Viewing all articles
Browse latest Browse all 971

Commented Issue: Interpolation data limits? [5725]

$
0
0
I'm using the following method:

IInterpolation ii = MathNet.Numerics.Interpolation.Interpolate.RationalWithoutPoles(points, values);

It seems to work when I'm passing in lists that are less than about 700 items, but fails when I'm using lists that are greater than about 800 items. I'm trying to interpolate an elevation when given a volume.

The attached text file has the raw data (861 items) Ignore the first two columns. The third is the elevation and forth is the volume. When using this data I'm getting either negative values or values that exceed the maximum elevation in the set. If I reduce the same set, by not including the first 200 items, it provides what appears to be a reasonable answer.

Thanks
Comments: Thanks. I just had a go at the data provided, but it seems to work fine for me. I used the following snippet, in LinqPad (hence the .Dump calls): ``` var samples = File.ReadAllLines(@"E:\Downloads\elev2vol.txt") .Select(l => l.Split(',').Skip(2).Select(s => Double.Parse(s.Trim())).ToArray()) .ToArray(); var x = samples.Select(z => z[0]).ToArray(); var y = samples.Select(z => z[1]).ToArray(); x.Length.Dump(); var ii = Interpolate.RationalWithoutPoles(x,y); double e1 = 0, e2 = 0, e3 = 0; int count = 0; for(int i=0;i<x.Length-1;i++) { count++; e1 += Math.Abs(ii.Interpolate(x[i]) - y[i]); e2 += Math.Abs(ii.Interpolate((x[i]+x[i+1])/2) - (y[i]+y[i+1])/2); e3 += Math.Abs(ii.Interpolate((4.0*x[i]+x[i+1])/5) - (4.0*y[i]+y[i+1])/5); } (e1 / count).Dump(); (e2 / count).Dump(); (e3 / count).Dump(); ``` returning: 861 (# samples) 0 (mean abs error at sample points, zero expected since this is an interpolation) 0.253021407617856 (mean abs error at center between samples, if it were linear between points) 0.156471265231335 (mean abs error at 1/5 between samples, if it were linear between points) Could you provide some concrete example values where the interpolation fails?

Viewing all articles
Browse latest Browse all 971

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>