thobbs / genartlib

Utilities for creating generative artwork with Clojure
MIT License
217 stars 20 forks source link

Fix triangular distribution #1

Closed mainej closed 6 years ago

mainej commented 6 years ago

This algorithm was taken from Wikipedia, but there b is the upper limit and c is the mode, whereas here b was the mode and c was the upper limit.

More concretely, this code was using the mode as the upper limit and vice-versa, breaking the algorithm. This change keeps the argument order as [lower mode upper] but fixes the algorithm.

A smaller commit would have been renaming the arguments from [a b c] to [a c b], to match the Wikipedia definitions. If you prefer that, that's fine, but I think these descriptive names clarify the algorithm slightly.

thobbs commented 6 years ago

Nice work catching that! Thank you for taking the time to open a PR, fix the problem, improve readability, and explain your changes! You're awesome.

mainej commented 6 years ago

Thank you for maintaining a cool little library, and more importantly, for writing about how to use it.