Skip to content

Instantly share code, notes, and snippets.

@axiak
Created April 10, 2012 04:20
Show Gist options
  • Save axiak/2348290 to your computer and use it in GitHub Desktop.
Save axiak/2348290 to your computer and use it in GitHub Desktop.
inverse = function (f, lower = -100, upper = 100) {
function (y) uniroot((function (x) f(x) - y), lower = lower, upper = upper)[1]
}
cdf = function (f) {
function (upper) integrate(f, 0.01, upper).value
}
f = 0.453 * exp(-1.036x) * sinh(sqrt(2.29x))
inverse_cdf = inverse(cdf(f))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment