You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Running the included example on RunKit only converges in ~15% of cases and depends strongly on the chosen initial values.
constLM=require("ml-levenberg-marquardt");// function that receives the parameters and returns// a function with the independent variable as a parameterfunctionsinFunction([a,b]){return(t)=>a*Math.sin(b*t);}letdata={x: [],y: []};lettrueParams=[2,2];letsampleFunction=sinFunction(trueParams);letnumSamples=1000;for(leti=0;i<numSamples;i++){letx=i/numSamples*2*Math.PI;data.x[i]=x;data.y[i]=sampleFunction(x);}letsuccess=0;letcounter=0;letmaxSampleRuns=250;while(maxSampleRuns--){letinitialValues=[Math.random()-0.5,Math.random()-0.5];constoptions={damping: 1.5,
initialValues,gradientDifference: 10e-2,maxIterations: 100,errorTolerance: 10e-3,};letfittedParams=LM(data,sinFunction,options);if(fittedParams.parameterError<0.01){success++;}counter++;if(counter%10===0){console.log(`Convergence Rate ${(100*success/counter).toFixed(1)}%`);}}
Running the included example on RunKit only converges in ~15% of cases and depends strongly on the chosen initial values.
results in
The text was updated successfully, but these errors were encountered: