Back to project page Sunset.
The source code is released under:
GNU General Public License
If you think the Android project Sunset listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package edu.rosehulman.mobilesunset; /*from w w w.j a v a2 s. c o m*/ public class OddsRatios { private static final double[] SVM_ODDS_RATIOS = { 0.25854313, 0.33757622, 0.10596326, 0.25854313, 0.12434276, 0.11397213, 0.11809662, 0.09041602, 0.10390898, 0.19366825, 0.12434276, 2.67833365, 0.29152187, 0.11809662, 0.09962085, 0.10596326, 0.29152187, 2.67833365, 0.55169550, 0.41749217, 0.13808207, 0.25854313, 0.12434276, 0.33757622, 2.67833365, 0.19366825, 0.19366825, 0.10938722, 0.19366825, 0.25854313, 0.12434276, 0.09041602, 0.19366825, 0.55169550, 0.16218040, 0.25854313, 0.19366825, 1.41563479, 0.33757622, 0.19366825, 4.62947466, 0.55169550, 0.09962085, 1.95115846, 0.12434276, 0.12434276, 0.33757622, 0.13808207, 0.33757622, 0.12434276, 0.09962085, 0.19366825, 0.10596326, 4.62947466, 0.16218040, 0.55169550, 0.11397213, 3.59066171, 0.29152187, 0.25854313, 0.41749217, 0.41749217, 0.04436861, 0.33757622, 9.04539522, 0.25854313, 0.75269500, 0.11809662, 0.75269500, 0.13808207, 0.11397213, 0.10938722, 0.10938722, 0.29152187, 3.59066171, 0.19366825, 3.59066171, 0.13808207, 0.75269500, 28.32825990, 0.09041602 }; private static final double[] TIMES_ODDS_RATIOS = { 0.00100000, 0.00100000, 0.00100000, 2.14705882, 0.00100000, 1.49461048, 0.00100000, 0.35778493, 0.00100000, 0.61974268, 0.50082154, 4.43993737, 0.00100000, 0.00100000, 1.85821007, 4.93458292, 0.64743888, 0.00100000, 0.70554913, 0.00100000, 0.00100000, 1.06364864, 0.00100000, 0.00100000, 1.01354687, 0.00100000, 0.67603741, 0.00100000, 0.00100000, 16.51275547, 2.15015743, 0.76735105, 2.21341651, 0.00100000, 13.05183791, 0.00100000, 0.00100000, 0.00100000, 2.57468592, 0.00100000, 0.00100000, 1.69688014, 0.00100000, 0.00100000, 3.53176971, 0.00100000, 0.00100000, 2.08883889, 0.00100000, 0.00100000, 0.00100000, 0.00100000, 0.00100000, 5.45825602, 0.00100000, 10.23788671, 0.00100000, 0.00100000, 0.00100000, 0.00100000, 0.00100000, 0.00100000, 0.00100000, 0.00100000, 0.00100000, 9.59217566, 0.00100000, 0.00100000, 0.00100000, 0.54194694, 4.18930029, 0.00100000, 6.90962671, 0.00100000, 2.61360265, 0.10434328, 0.00100000, 0.00100000, 0.00100000, 0.00100000, 0.00100000, 0.00100000, 0.15780573, 13.43100065, 1.10388731, 0.00100000, 1.41181839, 0.00100000, 3.61816946, 0.98604973, 2.41885292, 0.00100000, 0.00100000, 0.00100000, 0.30307506, 0.00100000, 0.00100000, 0.77630176, 1.76229561, 0.00100000, 2.20415209, 0.08674345, 0.00100000, 0.00100000, 0.47803910, 0.00100000, 0.52442956, 2.26166295, 0.00100000, 0.00100000, 0.00100000, 4.34454895, 4.34454895, 12.67519858, 18.79911475, 9.59217566, 3.45118366, 1.06364864, 6.90962671, 19.14797293, 0.42909876, 3.53176971, 18.79911475, 1.06364864, 9.07631625, 19.18146390, 16.51275547, 18.37545994, 0.42909876, 3.23410905, 17.46143937, 0.42909876, 0.42909876, 16.51275547, 10.23788671, 16.90018027, 3.54066247, 3.54066247, 0.00100000, 0.00100000, 6.90962671, 0.00100000, 9.07631625, 3.54066247, 18.71278080, 3.30321109, 18.96212593, 4.43993737, 10.45109450, 11.92117947, 15.20046149, 0.77630176, 4.43993737, 4.18930029, 7.83564522, 8.43746759, 8.43746759, 18.71278080, 10.23788671, 6.75090255, 17.63460542, 17.63460542, 19.11922424, 17.63460542, 18.10011271, 13.77880568, 17.63460542, 15.87538126, 15.20046149, 6.49100121, 2.31955375, 0.00100000, 0.00100000, 0.00100000, 4.93458292, 0.70554913, 2.15015743, 0.64743888, 0.65535500, 19.11922424, 0.50082154, 0.87686775, 13.05183791, 11.17732155, 8.43746759, 19.14797293, 11.61086209, 17.63460542, 15.20046149, 11.61086209, 1.36508663, 3.81374567, 3.23410905, 0.00100000, 18.49066720, 0.00100000, 13.43100065, 0.00100000, 0.00100000, 2.15015743, 3.45118366, 8.97965398, 2.66068912, 11.92117947, 17.63460542, 3.53176971, 2.85378714, 11.17732155, 19.14797293, 17.63460542, 17.10242930, 17.63460542, 17.46143937, 14.17943633, 9.07631625, 0.00100000, 14.91075946, 0.57418152, 0.00100000, 12.32642122, 0.00100000, 0.00100000, 15.20046149, 9.07631625, 2.67319872, 17.10242930, 17.63460542, 17.63460542, 17.10242930, 13.77880568, 16.28137124, 2.85448581, 1.85821007, 5.42702414, 0.00100000, 19.14797293, 3.93960183, 3.93960183, 7.83564522, 4.17574091, 3.54066247 }; public static final double MIN_SVM_OUTPUT = -4; public static final double MAX_SVM_OUTPUT = 4; public static final double MIN_TIMES_OUTPUT = -120; public static final double MAX_TIMES_OUTPUT = 120; public static double oddsRatioSVM(double x) { double MIN_RATIO = 0; double MAX_RATIO = 10000; double ratio = -1; if (x <= MIN_SVM_OUTPUT) { ratio = MIN_RATIO; } else if (x >= MAX_SVM_OUTPUT) { ratio = MAX_RATIO; } else { // get which bin it is in // TODO: check if length of SVM_ODDS_RATIOS is 80 double lowerBound = MIN_SVM_OUTPUT; double binWidth = (MAX_SVM_OUTPUT - MIN_SVM_OUTPUT) / (SVM_ODDS_RATIOS.length - 1); int index = (int) Math.ceil((x - lowerBound) / binWidth); ratio = SVM_ODDS_RATIOS[index]; } return ratio; } public static double oddsRatioTimes(double x) { // get which bin it is in double ratio = -1; double MIN_TIMES_RATIO = 0.001; if (x <= MIN_TIMES_OUTPUT || x >= MAX_TIMES_OUTPUT) ratio = MIN_TIMES_RATIO; else { // TODO: check if length of Times_ODDS_RATIOS is 240 double lowerBound = MIN_TIMES_OUTPUT; double binWidth = (MAX_TIMES_OUTPUT - MIN_TIMES_OUTPUT) / (TIMES_ODDS_RATIOS.length - 1); int index = (int) Math.ceil((x - lowerBound) / binWidth); ratio = TIMES_ODDS_RATIOS[index]; } return ratio; } }