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

Fit values to a function and evaluate it

$
0
0

@petrasvestartas wrote:

Hi,

I am totally new to math numerics and concepts of polynomials.

I would like to ask how can I fit an array of x and y values in order to get a function.

I attached the x and y datasets https://mega.nz/#!ppJW3axR!HJlOd0h0pEpVA1h-hRhO6vUjU6hK5tSoxntHby7-fbs
I tried this code:

double[] coef = MathNet.Numerics.Fit.Polynomial(x.ToArray(), y.ToArray(), 3);
System.Numerics.Complex n = MathNet.Numerics.Polynomial.Evaluate(2.2175597825, coef);

First I passsed x and y arrays and then I would like to evaluate this function by passing variable 2.2175597825 I expect to get number 1, but the result is something very random.

Maybe conceptually I am doing something wrong, but essentially I would like to fit values to some function and after getting that function, pass the x values and get the result.

Could you help me with this?

Currently I can plot this list of values:

Posts: 6

Participants: 3

Read full topic


Viewing all articles
Browse latest Browse all 224

Trending Articles