get rid of rollover rep

This commit is contained in:
Olivier Gagnon
2021-11-05 16:09:19 -04:00
parent ec76c2ecca
commit f8917473f8
4 changed files with 20 additions and 35 deletions
+5 -3
View File
@@ -9,11 +9,13 @@ export function favorToRep(f: number): number {
function fma(a: number, b: number, c: number): number {
return a * b + c;
}
const ex = fma(f, Math.log(51.0) - Math.log(50.0), Math.log(51.0));
return fma(500.0, Math.exp(ex), -25000.0);
const ex = fma(f - 1, Math.log(51.0) - Math.log(50.0), Math.log(51.0));
const raw = fma(500.0, Math.exp(ex), -25000.0);
return Math.round(raw * 10000) / 10000; // round to make things easier.
}
// Wolfram Alpha: 500 (50^(-n) 51^(n + 1) - 50) solve for n
export function repToFavor(r: number): number {
return -Math.log(25500 / (r + 25000)) / Math.log(51 / 50);
const raw = Math.log((r + 25000) / 25500) / Math.log(1.02) + 1;
return Math.round(raw * 10000) / 10000; // round to make things easier.
}