Last active
October 26, 2019 04:14
-
-
Save regakakobigman/469ce5e57d081ee59022ec50323020d3 to your computer and use it in GitHub Desktop.
A (totally fake) Beta distribution sampler for Godot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func randfb(curve: Curve) -> float: | |
# Returns a float mapped onto a symmetric distribution using a curve | |
# Also known as: a poor man's Beta distribution ;) | |
return symmetric_interpolate(randf(), curve) | |
func symmetric_interpolate(f: float, curve: Curve) -> float: | |
# Returns a float mapped onto a curve as if the curve were symmetric | |
return 0.5 + curve.interpolate(f) / (2 if randi()%2==0 else -2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment