Created
October 30, 2020 07:39
-
-
Save joonaojapalo/82b62b52b47dafbf19ec5c366011cd2d to your computer and use it in GitHub Desktop.
Gamma interpolation function
This file contains hidden or 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
//N = Math.ceil((x1 - x0) / d + 1)) | |
/** | |
* @param {Number} k Gamma. | |
* @param {Number} x Interpolation value [0, 1] | |
*/ | |
const f = (k, x) => (Math.exp(k * Math.max(0, Math.min(1, x)))-1)/(Math.exp(k)-1) | |
/** | |
* @param {Number} k Gamma | |
* @param {Number} N Number of steps | |
* @param {Number} y0 Start value. | |
* @param {Number} y1 End value. | |
*/ | |
const gi = (k, N, y0, y1) => { | |
let dy = (y1-y0) | |
return Array.from(Array(N)).map((_, i) => y0 + (y1 - y0) * f(k, i / (N-1))) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment