mljs / levenberg-marquardt

Curve fitting method in JavaScript
MIT License
70 stars 15 forks source link

Add simple linear regression example #51

Closed opatiny closed 1 year ago

opatiny commented 1 year ago

I have been trying to use the library and am struggling a bit with the results I'm obtaining. I think it would be really practical to have a very basic linear regression example to help understand how the library works.

I have also checked the testcases and haven't seen a very basic test easy to understand.

jobo322 commented 1 year ago

Hello @opatiny, how is the function that you provide, I think it is the problem.

It should has the shape

type Parameter = number[];
const func = ([a, b]) => {
   return (x) =>  a * x + b
}

I will generate some picture to add the example but hope it would useful

opatiny commented 1 year ago

Hi @jobo322 , thanks for your answer! I managed to get it work but I still think an example could be useful ;)

jacobq commented 1 year ago

@opatiny Now that you've figured it out, would you be willing to submit a PR that improves the documentation/examples? I can help edit & review it.