List of usage examples for org.apache.commons.math.distribution IntegerDistribution probability
double probability(int x);
From source file:geogebra.common.kernel.algos.AlgoBarChart.java
/** * Utility method, creates and loads list1 and list2 with classes and * probabilities for the probability distribution bar charts *///from w w w . j a va 2 s .co m private void loadDistributionLists(int first, int last, IntegerDistribution dist) throws Exception { boolean oldSuppress = cons.isSuppressLabelsActive(); cons.setSuppressLabelCreation(true); if (list1 != null) list1.remove(); list1 = new GeoList(cons); if (list2 != null) list2.remove(); list2 = new GeoList(cons); double prob; double cumProb = 0; for (int i = first; i <= last; i++) { list1.add(new GeoNumeric(cons, i)); prob = dist.probability(i); cumProb += prob; if (isCumulative != null && ((GeoBoolean) isCumulative).getBoolean()) list2.add(new GeoNumeric(cons, cumProb)); else list2.add(new GeoNumeric(cons, prob)); } cons.setSuppressLabelCreation(oldSuppress); }
From source file:geogebra.kernel.AlgoFunctionAreaSums.java
/** * Utility method, creates and loads list1 and list2 with classes and probabilities for * the probability distribution bar charts */// w ww .j a va 2 s . c om private void loadDistributionLists(int first, int last, IntegerDistribution dist) throws Exception { boolean oldSuppress = cons.isSuppressLabelsActive(); cons.setSuppressLabelCreation(true); if (list1 != null) list1.remove(); list1 = new GeoList(cons); if (list2 != null) list2.remove(); list2 = new GeoList(cons); double prob; double cumProb = 0; for (int i = first; i <= last; i++) { list1.add(new GeoNumeric(cons, i)); prob = dist.probability(i); cumProb += prob; if (isCumulative != null && ((GeoBoolean) isCumulative).getBoolean()) list2.add(new GeoNumeric(cons, cumProb)); else list2.add(new GeoNumeric(cons, prob)); } cons.setSuppressLabelCreation(oldSuppress); }
From source file:org.renjin.Distributions.java
/** * Calculates the value of the probability mass function at {@code x} * for the given discrete distribution//from w w w . j a v a 2s . c o m * * @param dist the discrete distribution * @param x the value * @param log whether to return the natural logarithm of the probability * @return the (natural logarithm) of the probability for the random variable * to take the value {@code x} */ private static double d(IntegerDistribution dist, double x, boolean log) { double d = dist.probability(x); if (log) { d = Math.log(d); } return d; }