Created
January 9, 2023 16:01
-
-
Save LimHyungTae/c447abf3f5e0ade5979844b55a5b2076 to your computer and use it in GitHub Desktop.
This file contains 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
#include <iostream> | |
#include <cmath> | |
using namespace std; | |
double prob2logOdds(double prob) { | |
return 2 * atanh(2 * prob - 1); | |
} | |
double logOdds2prob(double log_odds) { | |
return (tanh(log_odds / 2) + 1) / 2; | |
} | |
int main() | |
{ | |
cout << prob2logOdds(0.000000) << endl; | |
cout << prob2logOdds(0.000001) << endl; | |
cout << prob2logOdds(0.75) << endl; | |
cout << prob2logOdds(0.80) << endl; | |
cout << prob2logOdds(0.90) << endl; | |
cout << prob2logOdds(0.95) << endl; | |
cout << prob2logOdds(0.99) << endl; | |
cout << prob2logOdds(1.0) << endl; | |
cout << " = = = = = = = = = = " << endl; | |
cout << logOdds2prob(-2.0) << endl; | |
cout << logOdds2prob(0.0) << endl; | |
cout << logOdds2prob(0.5) << endl; | |
cout << logOdds2prob(3.0) << endl; | |
cout << logOdds2prob(4.6) << endl; | |
cout << logOdds2prob(30) << endl; | |
cout << logOdds2prob(60) << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-inf
-13.8155
1.09861
1.38629
2.19722
2.94444
4.59512
inf
= = = = = = = = = =
0.119203
0.5
0.622459
0.952574
0.990048
1
1