Skip to content

Instantly share code, notes, and snippets.

@nlw0
Last active January 15, 2017 21:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nlw0/7642a5cc8ac5ef884efda8cc92b48ff6 to your computer and use it in GitHub Desktop.
Save nlw0/7642a5cc8ac5ef884efda8cc92b48ff6 to your computer and use it in GitHub Desktop.
class RobustEstimator[Data, Hypothesis, Model](sampler: Seq[Data] => Hypothesis,
model_generator: Hypothesis => Model,
inlier_detector: Model => Data => Boolean) {
def estimate(data: Seq[Data], iterations: Int): Model = {
val minimal_sets = Seq.fill(iterations)(sampler(data))
val hypothetical_models = minimal_sets map model_generator
hypothetical_models.maxBy(m => data count inlier_detector(m))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment