export type DistFunction = (value: DataType, predictedValue: DataType) => number; export type FitFunction = (source: DataType[], destination: DataType[]) => number[]; export type ModelFunction = (source: DataType) => DataType; export type ModelCreator = (parameters: number[]) => ModelFunction; export interface RansacBaseOptions { /** * Number of elements of the random subset. By default, a linear regression is used, for which the minimal number of values is 2. * If another model is used, the minimal value of sampleSize is determined by the minimal number of values necessary to determine the model. * * @default 2 */ sampleSize?: number; /** * Maximal distance between model and inliers. The points for which the distance is equal to threshold are considered inliers. * * @default The median absolute deviation of the initial subset values to the model. */ threshold?: number; /** * Fitting function. * * @default Linear regression. */ fitFunction: FitFunction; /** * Function used to compute the distance from model to the value. */ distanceFunction: DistFunction; /** * Function that takes in parameters and outputs a model function. * * @default 100 */ modelFunction: ModelCreator; /** * Return current model if the number of inliers is bigger or equal to minNbInliers. * * @returns source.length */ minNbInliers?: number; /** * Seed for the random indices of the sample. * * @default undefined */ seed?: number; } export interface RansacProbabilityOptions extends RansacBaseOptions { /** * Stop iterating when enough iterations were made to have the givem probability that the best match has been found. * Probability should be a number between 0 and 1. * * @default 0.99 */ stopProbabilty?: number; /** * If known, specify the fraction of all the values that are outliers (estimatimation). * Value between 0 and 1. */ outliersFraction: number; } export interface RansacNbIterationsOptions extends RansacBaseOptions { /** * Maximal number of iterations of the algorithm. Will only be reached if a model never has minNbInliers. * * @default 100 */ maxNbIterations?: number; } export type RansacOptions = RansacNbIterationsOptions | RansacProbabilityOptions; export interface RansacOuput { /** * Parameters of the model with the most inliers. */ modelParameters: number[]; /** * Indices of the inliers for the best model. */ inliers: number[]; /** * Number of iterations of the ransac algorithm that were made. */ nbIterations: number; /** * Median distance from destination to model. */ error: number; } /** * RANdom SAmple Consensus algorithm: find the best model matching the data and ignoring outliers. * * @see https://en.wikipedia.org/wiki/Random_sample_consensus * @param source - The source data. * @param destination - The destination data. * @param options - RANSAC options. * @returns The model parameters and the corresponding inliers. */ export declare function ransac(source: DataType[], destination: DataType[], options: RansacOptions): RansacOuput; //# sourceMappingURL=index.d.ts.map