List of usage examples for java.lang Math log
@HotSpotIntrinsicCandidate public static double log(double a)
From source file:Main.java
public static double polarFunction(double t, double A, double B, double N) { return A / Math.log(B * Math.tan(t / (2 * N))); }
From source file:com.idylwood.Statistics.java
private static double[][] data(List<YahooFinance.Pair> pairs) { double[][] data = new double[pairs.size() - 1][2]; for (int i = 0; i < pairs.size() - 1; i++) { data[i][0] = Math.log(pairs.get(i + 1).first / pairs.get(i).first); data[i][1] = Math.log(pairs.get(i + 1).second / pairs.get(i).second); }/*w ww.j a v a 2 s . c o m*/ return data; }
From source file:Main.java
public static double gamma(double x) { double g = 1.0; double f;//from w w w .ja v a2 s .c o m if (x > 0.0) { while (x < 3.0) { g *= x; ++x; } f = (1.0 - 2.0 / (7.0 * Math.pow(x, 2.0)) * (1.0 - 2.0 / (3.0 * Math.pow(x, 2.0)))) / (30.0 * Math.pow(x, 2.0)); f = (1.0 - f) / (12.0 * x) + x * (Math.log(x) - 1.0); f = Math.exp(f) / g * Math.pow(6.283185307179586 / x, 0.5); } else { f = Double.POSITIVE_INFINITY; } return f; }
From source file:conceptor.chaos.Lyapunov.java
/** Given a DynamicalSystem, returns the maximul lyapunov exponent using the method outline by J.C. Sprott see: http://sprott.physics.wisc.edu/chaos/lyapexp.htm *//* ww w . j av a 2s . com*/ public static double computeLargestExponent(DynamicalSystem system) { double d0 = 10e-8; // First, evolve the system such that it's very likely to be on // the attractor (1000 iterations is a decent guess) evolveSystem(system, 10000); // Next, pick a test point a distance d0 away double[] testPoint = getTestPoint(system, d0); double[] x = system.getState(); double d1 = 0.0; double l = 0.0; // Evolve both the test point and the original for (int i = 0; i < 64100; i++) { testPoint = system.evolveOther(testPoint); x = system.evolve(); // Test for unbounded orbits if (isUnbounded(x)) { return Double.NaN; } // Compute distance d1 = MathArrays.distance(testPoint, x); // Compute lyapunov exponent this round if (i > 100) { l = l + Math.log(d1 / d0); } // Renormalize test point for (int j = 0; j < x.length; j++) { testPoint[j] = x[j] + (d0 / d1) * (testPoint[j] - x[j]); } } return l / (63999 * system.getStepSize()); }
From source file:edu.asu.ca.kaushik.algorithms.permvector.utils.SCPHF.java
public static int SCPHF_LLL(int t, int k, int v) { double covP = 1.0d; for (int i = 1; i < t; i++) { covP = covP * (1.0d - 1 / Math.pow(v, i)); }//from w w w .j a va 2s.c o m double q = 1.0d - covP; double d = CombinatoricsUtils.binomialCoefficientDouble(k, t) - CombinatoricsUtils.binomialCoefficientDouble(k - t, t); return (int) Math.ceil((1 + Math.log(d)) / (-Math.log(q))); }
From source file:com.opengamma.analytics.financial.model.volatility.surface.LogMoneyness.java
public LogMoneyness(final double strike, final double forward) { Validate.isTrue(strike > 0, "negative or zero strike"); Validate.isTrue(forward > 0, "negative or zero forward"); _value = Math.log(strike / forward); }
From source file:com.wegas.core.jcr.content.ContentConnector.java
/** * @param bytes/*from w w w . java2s.c o m*/ * @return string representation */ public static String bytesToHumanReadable(Long bytes) { Integer unit = 1024; if (bytes < unit) { return bytes + "B"; } Integer exponent = (int) (Math.log(bytes) / Math.log(unit)); String prefix = ("KMGTPE").charAt(exponent - 1) + ""; return String.format("%.1f%sB", bytes / Math.pow(unit, exponent), prefix); }
From source file:Util.java
/** * Returns the KL divergence, K(p1 || p2). * * The log is w.r.t. base 2. <p>/*from ww w.j av a 2 s . c om*/ * * *Note*: If any value in <tt>p2</tt> is <tt>0.0</tt> then the KL-divergence * is <tt>infinite</tt>. Limin changes it to zero instead of infinite. * */ public static double klDivergence(double[] p1, double[] p2) { double klDiv = 0.0; for (int i = 0; i < p1.length; ++i) { if (p1[i] == 0) { continue; } if (p2[i] == 0.0) { continue; } // Limin klDiv += p1[i] * Math.log(p1[i] / p2[i]); } return klDiv / log2; // moved this division out of the loop -DM }
From source file:gedi.util.math.stat.distributions.LfcDistribution.java
public static double mean(double a, double b) { return (Gamma.digamma(a) - Gamma.digamma(b)) / Math.log(2); }
From source file:com.opengamma.analytics.financial.timeseries.returns.ContinuouslyCompoundedGeometricMeanReturnCalculator.java
@Override public Double evaluate(final double[] x) { Validate.notNull(x, "x"); ArgumentChecker.notEmpty(x, "x"); final int n = x.length; double mult = Math.exp(x[0]); for (int i = 1; i < n; i++) { mult *= Math.exp(x[i]);/* w w w .j a v a 2s .com*/ } return Math.log(mult) / n; }