List of usage examples for org.apache.commons.math.distribution GammaDistributionImpl inverseCumulativeProbability
@Override public double inverseCumulativeProbability(final double p) throws MathException
p
. From source file:adams.gui.visualization.stats.paintlet.Gamma.java
/** * For calculating the dimensions of the plot area. *//*from w w w . j av a 2 s . co m*/ @Override public void calculateDimensions() { double median; GammaDistributionImpl gam = new GammaDistributionImpl(m_Shape, m_Scale); m_Sorted = SpreadSheetUtils.getNumericColumn(m_Data, m_Index); m_TransformedY = new double[m_Sorted.length]; Arrays.sort(m_Sorted); for (int i = 0; i < m_Sorted.length; i++) { median = ((i + 1) - 0.3) / (m_Sorted.length + 0.4); try { m_TransformedY[i] = gam.inverseCumulativeProbability(median); } catch (MathException e) { e.printStackTrace(); } } //If axis can handle the data if (m_AxisBottom.getType().canHandle(m_Sorted[0], m_Sorted[m_Sorted.length - 1])) { m_AxisBottom.setMinimum(m_Sorted[0]); m_AxisBottom.setMaximum(m_Sorted[m_Sorted.length - 1]); } else { getLogger().severe("errors in plotting"); } if (m_AxisLeft.getType().canHandle(m_TransformedY[0], m_TransformedY[m_TransformedY.length - 1])) { m_AxisLeft.setMinimum(m_TransformedY[0]); m_AxisLeft.setMaximum(m_TransformedY[m_TransformedY.length - 1]); } else { getLogger().severe("errors in plotting"); } m_AxisBottom.setAxisName(m_Data.getColumnName(m_Index) + ")"); m_AxisLeft.setAxisName("Inverse Gamma"); }
From source file:de.tum.bgu.msm.syntheticPopulationGenerator.kagawa.SyntheticPopJP.java
private static double translateIncome(int incomeClass, double[] incomeThresholds, GammaDistributionImpl q) throws MathException, MathException { //provide the income value for each person give the income class. //income follows a gamma distribution that was calibrated using the microdata. Income thresholds are calculated for the stiches double income; int finish = 0; double low = 0; double high = 1; if (incomeClass == 90) { income = 0; // kein Einkommen /* } else if (incomeClass == 50) { income = 0; // Selbstndige/r Landwirt/in in der Hauptttigkeit } else if (incomeClass == 99) { income = -1; //keine Angabe*/ } else {//from www .j a va 2s . c o m if (incomeClass == 1) { low = 0; high = incomeThresholds[0]; } else if (incomeClass == 50) { // Selbstndige/r Landwirt/in in der Hauptttigkeit low = 0; //give them a random income following the distribution high = 1; } else if (incomeClass == 99) { //keine Angabe low = 0; //give them a random income following the distribution high = 1; } else if (incomeClass == incomeThresholds.length + 1) { low = incomeThresholds[incomeThresholds.length - 1]; high = 1; } else { int i = 2; while (finish == 0) { if (incomeClass > i) { i++; } else { finish = 1; low = incomeThresholds[i - 2]; high = incomeThresholds[i - 1]; } } } Random rnd = new Random(); double cummulativeProb = rnd.nextDouble() * (high - low) + low; income = q.inverseCumulativeProbability(cummulativeProb); } return income; }
From source file:de.tum.bgu.msm.syntheticPopulationGenerator.capeTown.SyntheticPopCT.java
private static double translateIncome(int incomeClass, double[] incomeThresholds, GammaDistributionImpl q) throws MathException { //provide the income value for each person give the income class. //income follows a gamma distribution that was calibrated using the microdata. Income thresholds are calculated for the stiches double income; int finish = 0; double low = 0; double high = 1; if (incomeClass == 90) { income = 0; // kein Einkommen /* } else if (incomeClass == 50) { income = 0; // Selbstndige/r Landwirt/in in der Hauptttigkeit } else if (incomeClass == 99) { income = -1; //keine Angabe*/ } else {/* w w w.j a v a 2 s.com*/ if (incomeClass == 1) { low = 0; high = incomeThresholds[0]; } else if (incomeClass == 50) { // Selbstndige/r Landwirt/in in der Hauptttigkeit low = 0; //give them a random income following the distribution high = 1; } else if (incomeClass == 99) { //keine Angabe low = 0; //give them a random income following the distribution high = 1; } else if (incomeClass == incomeThresholds.length + 1) { low = incomeThresholds[incomeThresholds.length - 1]; high = 1; } else { int i = 2; while (finish == 0) { if (incomeClass > i) { i++; } else { finish = 1; low = incomeThresholds[i - 2]; high = incomeThresholds[i - 1]; } } } double cummulativeProb = SiloUtil.getRandomNumberAsDouble() * (high - low) + low; income = q.inverseCumulativeProbability(cummulativeProb); } return income; }