Skip to content

Instantly share code, notes, and snippets.

@regakakobigman
Last active October 26, 2019 04:14
Show Gist options
  • Save regakakobigman/469ce5e57d081ee59022ec50323020d3 to your computer and use it in GitHub Desktop.
Save regakakobigman/469ce5e57d081ee59022ec50323020d3 to your computer and use it in GitHub Desktop.
A (totally fake) Beta distribution sampler for Godot
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