List of usage examples for java.lang Math pow
@HotSpotIntrinsicCandidate public static double pow(double a, double b)
From source file:eu.betaas.taas.securitymanager.taastrustmanager.taastrustcalculator.StatisticsCalculator.java
public boolean calculateNumericVariance(double[] values) { double alpha = 0.05; double mean = StatUtils.mean(values); double variance = StatUtils.variance(values); double expected = Math.pow(mean * 0.05, 2); //double expected = 0.01; double degFreedom = values.length - 1.0; double T = (degFreedom * variance) / expected; logger.debug("Mean = " + mean); logger.debug("Standard Deviation = " + Math.sqrt(variance)); logger.debug("Test Statistic calculated T = " + T); ChiSquaredDistribution myDist = new ChiSquaredDistribution(degFreedom); double myTLeft = myDist.inverseCumulativeProbability(alpha / 2.0); double myTRight = myDist.inverseCumulativeProbability(1.0 - alpha / 2.0); logger.debug("Boundaries: " + myTLeft + " to " + myTRight); // Determine if z score is in the region of acceptance if ((myTLeft <= T) && (T <= myTRight)) { // H0 -> Variance of the data is equal to the expected one return true; }/* ww w. j a v a 2s. c o m*/ // H1 -> Variance of the data is different to the expected one return false; }
From source file:fr.ign.cogit.geoxygene.sig3d.gui.window.result.DissimilarityCalculationDialog.java
/** * Affiche un graphique l'aide de 2 nuages de points * /* w ww .j a va 2 s.c o m*/ * @param title the frame title. */ public DissimilarityCalculationDialog(final String title, IDirectPositionList dpl1, IDirectPositionList dpl2) { super(); final XYSeries series = new XYSeries("Objet 1"); int nbElem = dpl1.size(); for (int i = 0; i < nbElem - 1; i++) { series.add((dpl1.get(i + 1).getX() + dpl1.get(i).getX()) / 2, dpl1.get(i).getY()); } final XYSeries series2 = new XYSeries("Objet 2"); int nbElem2 = dpl2.size(); for (int i = 0; i < nbElem2 - 1; i++) { series2.add((dpl2.get(i + 1).getX() + dpl2.get(i).getX()) / 2, dpl2.get(i).getY()); } double valeur = 0; // Affiche la diffrence en norme L2 des 2 graphiques for (int i = 0; i < nbElem; i++) { valeur = valeur + Math.pow(dpl1.get(i).getY() - dpl2.get(i).getY(), 2); } valeur = Math.sqrt(valeur) / (1024 * 512); final XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(series); dataset.addSeries(series2); final JFreeChart chart = ChartFactory.createXYLineChart("XY Series Demo", "Distance : " + valeur, Messages.getString("Result.PointFD"), dataset, PlotOrientation.VERTICAL, true, true, false); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); this.setContentPane(chartPanel); }
From source file:de.tud.kom.p2psim.impl.network.modular.st.ploss.StaticPacketLoss.java
@Override public boolean shallDrop(ModularNetMessage msg, ModularNetLayer nlSender, ModularNetLayer nlReceiver, NetMeasurementDB db) {/*w w w . j a v a2 s . c o m*/ // If the message consists of multiple fragments, the loss probability // will be the probability that all fragments have arrived, and // every fragment has the probability of "ratio" to be dropped return rand.nextDouble() < 1d - Math.pow(1d - ratio, msg.getNoOfFragments()); }
From source file:forge.quest.QuestUtilUnlockSets.java
/** * Consider unlocking a new expansion in limited quest format. * @param qData the QuestController for the current quest * @param freeUnlock this unlock is free (e.g., a challenge reward), NOT IMPLEMENTED YET * @param presetChoices List<CardEdition> a pregenerated list of options, NOT IMPLEMENTED YET * @return CardEdition, the unlocked edition if any. */// w w w . java2 s . c om public static ImmutablePair<CardEdition, Integer> chooseSetToUnlock(final QuestController qData, final boolean freeUnlock, List<CardEdition> presetChoices) { if (qData.getFormat() == null || !qData.getFormat().canUnlockSets()) { return null; } final ReadPriceList prices = new ReadPriceList(); final Map<String, Integer> mapPrices = prices.getPriceList(); final List<ImmutablePair<CardEdition, Integer>> setPrices = new ArrayList<ImmutablePair<CardEdition, Integer>>(); for (CardEdition ed : getUnlockableEditions(qData)) { int price = UNLOCK_COST; if (mapPrices.containsKey(ed.getName() + " Booster Pack")) { price = Math.max( new Double(30 * Math.pow(Math.sqrt(mapPrices.get(ed.getName() + " Booster Pack")), 1.70)) .intValue(), UNLOCK_COST); } setPrices.add(ImmutablePair.of(ed, price)); } final String setPrompt = "You have " + qData.getAssets().getCredits() + " credits. Unlock:"; List<String> options = new ArrayList<String>(); for (ImmutablePair<CardEdition, Integer> ee : setPrices) { options.add(String.format("%s [PRICE: %d credits]", ee.left.getName(), ee.right)); } int index = options.indexOf(SGuiChoose.oneOrNone(setPrompt, options)); if (index < 0 || index >= options.size()) { return null; } ImmutablePair<CardEdition, Integer> toBuy = setPrices.get(index); int price = toBuy.right; CardEdition choosenEdition = toBuy.left; if (qData.getAssets().getCredits() < price) { SOptionPane.showMessageDialog( "Unfortunately, you cannot afford that set yet.\n" + "To unlock " + choosenEdition.getName() + ", you need " + price + " credits.\n" + "You have only " + qData.getAssets().getCredits() + " credits.", "Failed to unlock " + choosenEdition.getName(), null); return null; } if (!SOptionPane .showConfirmDialog( "Unlocking " + choosenEdition.getName() + " will cost you " + price + " credits.\n" + "You have " + qData.getAssets().getCredits() + " credits.\n\n" + "Are you sure you want to unlock " + choosenEdition.getName() + "?", "Confirm Unlocking " + choosenEdition.getName())) { return null; } return toBuy; }
From source file:com.opengamma.analytics.math.statistics.estimation.StudentTDistributionMaximumLikelihoodEstimator.java
@Override public ProbabilityDistribution<Double> evaluate(final double[] x) { Validate.notNull(x, "x"); ArgumentChecker.notEmpty(x, "x"); final double[] standardized = getStandardizedData(x); final Function1D<Double, Double> f = new Function1D<Double, Double>() { @SuppressWarnings("synthetic-access") @Override//from w w w .j a v a 2s .com public Double evaluate(final Double nu) { double sum = 0; for (final double t : standardized) { sum += Math.log(_gamma.evaluate((nu + 1) / 2.) * Math.pow(1 + t * t / (nu - 2), -(nu + 1) / 2.) / Math.sqrt(Math.PI * (nu - 2)) / _gamma.evaluate(nu / 2.)); } return -sum; } }; return new StudentTDistribution(_minimizer.minimize(f, 0.0, 3., 10.)); }
From source file:com.galenframework.specs.RangeValue.java
public double asDouble() { return ((double) value) / Math.pow(10, precision); }
From source file:de.biomedical_imaging.ij.steger.Convol.java
public double phi2(double x, double sigma) { double t;/*from w w w .j a v a 2s . co m*/ t = x / sigma; return -x * SQRT_2_PI_INV / Math.pow(sigma, 3.0) * Math.exp(-0.5 * t * t); }
From source file:org.wallerlab.yoink.adaptive.smooth.smoothfunction.PermutedSmoothFunction.java
/** * this smooth function is used in PAP and SAP methods. for details please * see: Heyden, Andreas, Hai Lin, and Donald G. Truhlar. "Adaptive * partitioning in combined quantum mechanical and molecular mechanical * calculations of potential energy functions for multiscale simulations." * The Journal of Physical Chemistry B 111.9 (2007): 2231-2241. * /*from ww w . jav a 2 s .c o m*/ * @param currentValue * , currentValue(variable) in smooth function * @param min * , minimum value in smooth function * @param max * , maximum value in smooth function * @return smooth factor */ public double evaluate(double currentValue, double min, double max) { double smoothFactor; if (currentValue > max) { smoothFactor = 0; } else if (currentValue < min) { smoothFactor = 1; } else { double alpha = (currentValue - min) / (max - min); smoothFactor = -6 * (Math.pow((alpha), 5)) + 15 * (Math.pow((alpha), 4)) - 10 * (Math.pow((alpha), 3)) + 1; } return smoothFactor; }
From source file:ChartThread.java
public synchronized void changeFrames(int frames) { this.frames = frames; if (unidad >= Math.pow(10, 11)) this.frames += 775; }