List of usage examples for java.lang Math log
@HotSpotIntrinsicCandidate public static double log(double a)
From source file:bide.math.NormalDistribution.java
public static double logPdf(double x, double m, double sd) { double a = 1.0 / (MATH_SQRT_2PI * sd); double b = -(x - m) * (x - m) / (2.0 * sd * sd); return Math.log(a) + b; }
From source file:edu.asu.ca.kaushik.algorithms.twostage.TwoStageOnlineGreedy.java
@Override protected int partialArraySize(int t, int k, int v) { //Side effect; bad style this.second = new ListCA(t, k, v); this.t = t;/*www. j a v a2 s .com*/ this.k = k; this.v = v; // function proper double vpowt = Math.pow(v, t); double n1 = Math.ceil( Math.log(CombinatoricsUtils.binomialCoefficientDouble(k, t) * vpowt * Math.log(vpowt / (vpowt - 1))) / Math.log(vpowt / (vpowt - 1))); double denom = Math.log(1 - (1 / vpowt)); double n = (Math.log(this.times) + n1 * denom) / denom; return (int) Math.ceil(n); }
From source file:de.tudarmstadt.ukp.dkpro.bigdata.collocations.AssociationMetrics.java
public double mutual_information() { return Math.log(o11 / e11); }
From source file:com.analog.lyric.dimple.factorfunctions.Poisson.java
public Poisson(double lambda) // For fixed lambda { this();/*w w w .j a v a 2 s . c o m*/ if (lambda <= 0) throw new DimpleException("lambda must be greater than zero."); _lambda = lambda; _logLambda = Math.log(lambda); _lambdaParameterConstant = true; _firstDirectedToIndex = 0; }
From source file:com.opengamma.analytics.math.statistics.distribution.LaplaceDistribution.java
/** * {@inheritDoc}/*w w w. j a v a 2 s . c o m*/ */ @Override public double getInverseCDF(final Double p) { Validate.notNull(p); Validate.isTrue(p >= 0 && p <= 1, "Probability must lie between 0 and 1 (inclusive)"); return _mu - _b * Math.signum(p - 0.5) * Math.log(1 - 2 * Math.abs(p - 0.5)); }
From source file:com.opengamma.analytics.financial.equity.variance.pricing.RealizedVariance.java
@Override public Double evaluate(final VarianceSwap swap) { double[] obs = swap.getObservations(); int nObs = obs.length; if (nObs < 2) { return 0.0; }/*from ww w . ja v a 2 s . co m*/ Double[] weights = new Double[obs.length - 1]; if (swap.getObservationWeights().length == 0) { Arrays.fill(weights, 1.0); } else if (swap.getObservationWeights().length == 1) { Arrays.fill(weights, swap.getObservationWeights()[0]); } else { int nWeights = swap.getObservationWeights().length; Validate.isTrue(nWeights == nObs - 1, "If provided, observationWeights must be of length one less than observations, as they weight returns log(obs[i]/obs[i-1])." + " Found " + nWeights + " weights and " + nObs + " observations."); } Validate.isTrue(obs[0] != 0.0, "In VarianceSwap, the first observation is zero so the estimate of RealizedVariance is undefined. Check time series."); double logReturns = 0; for (int i = 1; i < nObs; i++) { Validate.isTrue(obs[i] != 0.0, "Encountered an invalid observation of zero in VarianceSwap at " + i + "'th observation. " + "The estimate of RealizedVariance is undefined. Check time series."); logReturns += weights[i - 1] * FunctionUtils.square(Math.log(obs[i] / obs[i - 1])); } return logReturns / (nObs - 1) * swap.getAnnualizationFactor(); }
From source file:edu.berkeley.sparrow.examples.ProtoFrontendAsync.java
public static double generateInterarrivalDelay(Random r, double lambda) { double u = r.nextDouble(); return -Math.log(u) / lambda; }
From source file:com.opengamma.analytics.financial.model.option.pricing.analytic.AsymmetricPowerOptionModel.java
/** * {@inheritDoc}/*from ww w.j a va 2 s . c o m*/ */ @Override public Function1D<StandardOptionDataBundle, Double> getPricingFunction( final AsymmetricPowerOptionDefinition definition) { Validate.notNull(definition); final Function1D<StandardOptionDataBundle, Double> pricingFunction = new Function1D<StandardOptionDataBundle, Double>() { @SuppressWarnings("synthetic-access") @Override public Double evaluate(final StandardOptionDataBundle data) { Validate.notNull(data); final double s = data.getSpot(); final double k = definition.getStrike(); final double t = definition.getTimeToExpiry(data.getDate()); final double sigma = data.getVolatility(t, k); final double r = data.getInterestRate(t); final double b = data.getCostOfCarry(); final double power = definition.getPower(); final double sigmaT = sigma * Math.sqrt(t); final double d1 = (Math.log(s / Math.pow(k, 1. / power)) + t * (b + sigma * sigma * (power - 0.5))) / sigmaT; final double d2 = d1 - power * sigmaT; final int sign = definition.isCall() ? 1 : -1; final double df1 = Math .exp(((power - 1) * (r + power * sigma * sigma * 0.5) - power * (r - b)) * t); final double df2 = Math.exp(-r * t); return sign * (Math.pow(s, power) * df1 * NORMAL.getCDF(sign * d1) - df2 * k * NORMAL.getCDF(sign * d2)); } }; return pricingFunction; }
From source file:dr.math.distributions.TruncatedDistribution.java
public double logPdf(double x) { return Math.log(pdf(x)); }
From source file:dk.netarkivet.common.utils.JMXUtils.java
/** The maximum number of times we back off on getting an mbean or a job. * The cumulative time trying is 2^(MAX_TRIES) milliseconds, * thus the constant is defined as log_2(TIMEOUT), as set in settings. * @return The number of tries//from ww w .j a v a 2 s.c o m */ public static int getMaxTries() { return (int) Math.ceil(Math.log((double) timeoutInseconds * DOUBLE_SECONDS_IN_MILLIS) / Math.log(2.0)); }