Skip to content

Instantly share code, notes, and snippets.

View nlw0's full-sized avatar

Nicolau Leal Werneck nlw0

View GitHub Profile

Keybase proof

I hereby claim:

  • I am nlw0 on github.
  • I am nlw (https://keybase.io/nlw) on keybase.
  • I have a public key whose fingerprint is 10B8 F2FF 91E3 C3D8 1644 1357 AD36 B217 6919 3B91

To claim this, I am signing this object:

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))
}
}
import estimation.RobustEstimator
import geometry.{Line, Point}
import scala.math.abs
import scala.util.Random
object TestRANSAC extends App {
val n_outliers = 100
val n_inliers = 100
import scala.math.sqrt
import scala.util.Random
trait Vec2d {
def x: Double
def y: Double
def -(that: Point): Point = Point(this.x - that.x, this.y - that.y)
@nlw0
nlw0 / Quicksoft.scala
Created May 5, 2017 18:41
Quicksort in Scala, for my blog
object Quicksort extends App {
val inputStream = io.Source.fromInputStream(System.in)
val data = inputStream.getLines().toStream map (_.toInt)
quicksort(data) foreach { println(_) }
def quicksort(x: Stream[Int]): Stream[Int] = if (x.isEmpty) Stream() else {
val pivot = x.head
val (a, b) = x.tail.partition(_ <= pivot)
quicksort(a) #::: pivot #:: quicksort(b)
object Quicksort extends App {
val inputStream = io.Source.fromInputStream(System.in)
val data = inputStream.getLines().toList map (_.toInt)
quicksort(data) foreach { println(_) }
def quicksort(x: List[Int]): List[Int] = if (x.isEmpty) List() else {
val pivot = x.head
val (a, b) = x.tail.partition(_ <= pivot)
val coisa = quicksort(a) ::: pivot :: quicksort(b)
@nlw0
nlw0 / orthopoints.ipynb
Last active June 17, 2017 22:08
How to use a root-finding algorithm to find points over a parametric curve where it becomes orthogonal to some given point in space
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nlw0
nlw0 / homotex.ipynb
Created September 25, 2017 21:08
Homography and image spectral analysis
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nlw0
nlw0 / robust_fit_ad.ipynb
Created September 26, 2017 12:02
Continuous non-linear optimization for robust fitting using AD to get derivatives functions
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nlw0
nlw0 / painter_color_classifier.ipynb
Last active October 5, 2017 20:29
Painter classification based on color histograms, trying to illustrate how much spacial information is necessary and/or important (WIP)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.