/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/ml-ransac@1.0.0/lib/index.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
"use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.ransac=void 0;const ml_array_median_1=__importDefault(require("ml-array-median")),ml_random_1=__importDefault(require("ml-random")),getNbIterations_1=require("./utils/getNbIterations");function ransac(e,t,r){let n=0;n=r.minNbInliers?getNbValues(r.minNbInliers,e.length):e.length;const{sampleSize:i=2,threshold:o=1,fitFunction:a,distanceFunction:s,modelFunction:l,seed:u}=r;if(e.length!==t.length)throw new Error("source and destination data should have the same length");let m;if("outliersFraction"in r){const{stopProbabilty:e=.99}=r;m=(0,getNbIterations_1.getNbIterations)(e,r.outliersFraction,i)}else m=r.maxNbIterations?r.maxNbIterations:100;let c=0,d=0,_=[],h=[],f=0,b=[];for(void 0!==u&&(b=new ml_random_1.default(u).choice(m,{size:m}));c<m;){let r;c++,r=void 0!==u?new ml_random_1.default(b[c]).choice(e.length,{size:i}):(new ml_random_1.default).choice(e.length,{size:i});const m=[],p=[];for(let n of r)m.push(e[n]),p.push(t[n]);const g=a(m,p),I=l(g);let N=[];for(let t of e)N.push(I(t));let v=0,w=[],x=[],y=0;for(let e=0;e<t.length;e++){if(r.includes(e)){v++,w.push(e);continue}const n=s(t[e],N[e]);x.push(n),n<o&&(v++,w.push(e))}if(y=(0,ml_array_median_1.default)(x),v>d&&(d=v,_=w,h=g,f=y,v>=n))return{modelParameters:g,inliers:w,nbIterations:c,error:y}}return{modelParameters:h,inliers:_,nbIterations:m,error:f}}function getNbValues(e,t){return Number.isInteger(e)?e:Math.ceil(e*t)}exports.ransac=ransac;
//# sourceMappingURL=/sm/71a7e726775bebe562098f260aa094c2a5e51002e86c9d182dd2299e178415c1.map