mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-12-28 11:00:34 +00:00
improved dhrg::logistic
This commit is contained in:
parent
fd1be4beb8
commit
bb22d363c8
@ -40,10 +40,13 @@ bool dhrg_animate(int sym, int uni);
|
||||
/* for logistic regression */
|
||||
struct logistic {
|
||||
ld R, T;
|
||||
ld yes(ld d) { return 1/(1 + exp((d-R) / 2 / T)); }
|
||||
ld no(ld d) { return 1/(1 + exp(-(d-R) / 2 / T)); }
|
||||
ld lyes(ld d) { return log(yes(d)); }
|
||||
ld lno(ld d) { return log(no(d)); }
|
||||
ld yes1(ld d) { return 1/(1 + exp(d)); }
|
||||
ld no1(ld d) { return 1/(1 + exp(-d)); }
|
||||
ld nor(ld d) { return (d-R) / 2 / T; }
|
||||
ld yes(ld d) { return yes1(nor(d)); }
|
||||
ld no(ld d) { return no1(nor(d)); }
|
||||
ld lyes(ld d) { d = nor(d); return d > 200 ? -d : log(yes1(d)); }
|
||||
ld lno(ld d) { d = nor(d); return d < -200 ? d : log(no1(d)); }
|
||||
logistic() {}
|
||||
logistic(ld _R, ld _T) : R(_R), T(_T) {}
|
||||
void setRT(ld _R, ld _T) { R = _R; T = _T; }
|
||||
|
Loading…
Reference in New Issue
Block a user