Java Code Examples for java.lang.Math#log()
The following examples show how to use
java.lang.Math#log() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Logarithm.java From Llunatic with GNU General Public License v3.0 | 6 votes |
public Object log(Object param) throws ParseException { if (param instanceof Complex) { return ((Complex)param).log().div(CLOG10); } else if (param instanceof Number) { double num = ((Number) param).doubleValue(); if( num >= 0) return new Double(Math.log(num)/LOG10); else if(num != num) return new Double(Double.NaN); else { Complex temp = new Complex(num); return temp.log().div(CLOG10); } } throw new ParseException("Invalid parameter type"); }
Example 2
Source File: AG.java From KEEL with GNU General Public License v3.0 | 6 votes |
/** Inicialization of the population */ public void Initialize () { int i, j; last = (int) ((prob_cruce * long_poblacion) - 0.5); Trials = 0; if (prob_mutacion < 1.0) { Mu_next = (int) (Math.log(Randomize.Rand()) / Math.log(1.0 - prob_mutacion)); Mu_next++; } else Mu_next = 1; for (j=0; j<n_genes; j++) New[0].Gene[j] = '1'; New[0].n_e = 1; for (i=1; i < long_poblacion; i++) { for (j=0; j<n_genes; j++) if (Randomize.RandintClosed(0,1) == 0) New[i].Gene[j] = '0'; else New[i].Gene[j] = '1'; New[i].n_e = 1; } }
Example 3
Source File: NaturalLogarithm.java From Llunatic with GNU General Public License v3.0 | 6 votes |
public Object ln(Object param) throws ParseException { if (param instanceof Complex) { return ((Complex)param).log(); } else if (param instanceof Number) { // Now returns Complex if param is <0 double num = ((Number) param).doubleValue(); if( num >= 0) return new Double(Math.log(num)); else if(num != num) return new Double(Double.NaN); else { Complex temp = new Complex(num); return temp.log(); } } throw new ParseException("Invalid parameter type"); }
Example 4
Source File: AG_Sel.java From KEEL with GNU General Public License v3.0 | 5 votes |
/** Inicialization of the population */ public void Initialize() { int i, j; last = (int) ( (prob_cruce * long_poblacion) - 0.5); Trials = 0; if (prob_mutacion < 1.0) { Mu_next = (int) (Math.log(Randomize.Rand()) / Math.log(1.0 - prob_mutacion)); Mu_next++; } else { Mu_next = 1; } for (j = 0; j < n_genes; j++) { New[0].GeneSel[j] = '1'; } New[0].n_e = 1; for (i = 1; i < long_poblacion; i++) { for (j = 0; j < n_genes; j++) { if (Randomize.RandintClosed(0, 1) == 0) { New[i].GeneSel[j] = '0'; } else { New[i].GeneSel[j] = '1'; } } New[i].n_e = 1; } }
Example 5
Source File: AG_Sel.java From KEEL with GNU General Public License v3.0 | 5 votes |
void Mutacion_Uniforme() { int posiciones, i, j; double m; posiciones = n_genes * long_poblacion; if (prob_mutacion > 0) { while (Mu_next < posiciones) { /* we determinate the chromosome and the GeneSel */ i = Mu_next / n_genes; j = Mu_next % n_genes; /* we mutate the GeneSel */ if (New[i].GeneSel[j] == '0') { New[i].GeneSel[j] = '1'; } else { New[i].GeneSel[j] = '0'; } New[i].n_e = 1; /* we calculate the next position */ if (prob_mutacion < 1) { m = Randomize.Rand(); Mu_next += (int) (Math.log(m) / Math.log(1.0 - prob_mutacion)) + 1; } else { Mu_next += 1; } } } Mu_next -= posiciones; }
Example 6
Source File: AG.java From KEEL with GNU General Public License v3.0 | 5 votes |
/** Inicialization of the population */ public void Initialize() { int i, j; last = (int) ( (prob_cruce * long_poblacion) - 0.5); Trials = 0; if (prob_mutacion < 1.0) { Mu_next = (int) (Math.log(Randomize.Rand()) / Math.log(1.0 - prob_mutacion)); Mu_next++; } else { Mu_next = 1; } for (j = 0; j < n_genes; j++) { New[0].GeneSel[j] = '1'; } New[0].n_e = 1; for (i = 1; i < long_poblacion; i++) { for (j = 0; j < n_genes; j++) { if (Randomize.RandintClosed(0, 1) == 0) { New[i].GeneSel[j] = '0'; } else { New[i].GeneSel[j] = '1'; } } New[i].n_e = 1; } }
Example 7
Source File: Utils.java From KEEL with GNU General Public License v3.0 | 5 votes |
/** * Returns the log-odds for a given probabilitiy. * * @param prob the probabilitiy * * @return the log-odds after the probability has been mapped to * [Utils.SMALL, 1-Utils.SMALL] */ public static /*@pure@*/ double probToLogOdds(double prob) { if (gr(prob, 1) || (sm(prob, 0))) { throw new IllegalArgumentException("probToLogOdds: probability must " + "be in [0,1] "+prob); } double p = SMALL + (1.0 - 2 * SMALL) * prob; return Math.log(p / (1 - p)); }
Example 8
Source File: AG_Tun_des.java From KEEL with GNU General Public License v3.0 | 5 votes |
/** Mutation Non Uniform */ public void Mutacion_No_Uniforme (long Gen, long n_generaciones) { int posiciones, i, j; double nval, m; posiciones = n_genes * long_poblacion; if (prob_mutacion>0) { while (Mu_next<posiciones) { /* we determinate the chromosome and the gene */ i = Mu_next / n_genes; j = Mu_next % n_genes; /* we mutate the gene */ if (Randomize.Rand()<0.5) nval = New[i].Gene[j] + delta (Gen, intervalos[j].max-New[i].Gene[j], n_generaciones); else nval=New[i].Gene[j] - delta (Gen, New[i].Gene[j]-intervalos[j].min, n_generaciones); New[i].Gene[j]=nval; New[i].n_e = 1; /* we calculate the next position */ if (prob_mutacion<1) { m = Randomize.Rand(); Mu_next+= (int) (Math.log(m)/Math.log(1.0-prob_mutacion)); Mu_next++; } else Mu_next+=1; } Mu_next -= posiciones; } }
Example 9
Source File: AG.java From KEEL with GNU General Public License v3.0 | 5 votes |
/** Mutation Non Uniform */ public void Mutacion_No_Uniforme (long Gen, long n_generaciones) { int posiciones, i, j; double nval, m; posiciones = n_genes * long_poblacion; if (prob_mutacion>0) { while (Mu_next<posiciones) { /* we determinate the chromosome and the gene */ i = Mu_next / n_genes; j = Mu_next % n_genes; /* we mutate the gene */ if (Randomize.Rand()<0.5) nval = New[i].Gene[j] + delta (Gen, intervalos[j].max-New[i].Gene[j], n_generaciones); else nval=New[i].Gene[j] - delta (Gen, New[i].Gene[j]-intervalos[j].min, n_generaciones); New[i].Gene[j]=nval; New[i].n_e = 1; /* we calculate the next position */ if (prob_mutacion<1) { m = Randomize.Rand(); Mu_next+= (int) (Math.log(m)/Math.log(1.0-prob_mutacion)); Mu_next++; } else Mu_next+=1; } Mu_next -= posiciones; } }
Example 10
Source File: Utils.java From KEEL with GNU General Public License v3.0 | 5 votes |
/** * Returns the log-odds for a given probabilitiy. * * @param prob the probabilitiy * * @return the log-odds after the probability has been mapped to * [Utils.SMALL, 1-Utils.SMALL] */ public static /*@pure@*/ double probToLogOdds(double prob) { if (gr(prob, 1) || (sm(prob, 0))) { throw new IllegalArgumentException("probToLogOdds: probability must " + "be in [0,1] "+prob); } double p = SMALL + (1.0 - 2 * SMALL) * prob; return Math.log(p / (1 - p)); }
Example 11
Source File: AG.java From KEEL with GNU General Public License v3.0 | 5 votes |
void Mutacion_Uniforme () { int posiciones, i, j; double m; posiciones = n_genes * long_poblacion; if (prob_mutacion>0) { while (Mu_next<posiciones) { /* we determinate the chromosome and the gene */ i = Mu_next / n_genes; j = Mu_next % n_genes; /* we mutate the gene */ if (New[i].Gene[j]=='0') New[i].Gene[j]='1'; else New[i].Gene[j]='0'; New[i].n_e=1; /* we calculate the next position */ if (prob_mutacion<1) { m = Randomize.Rand(); Mu_next += (int) (Math.log(m) / Math.log(1.0 - prob_mutacion)) + 1; } else Mu_next += 1; } } Mu_next -= posiciones; }
Example 12
Source File: AG.java From KEEL with GNU General Public License v3.0 | 4 votes |
/** Uniform Non Mutation */ public void Mutacion_Thrift_No_Uniforme(long Gen, long n_generaciones, BaseD base_datos) { int posiciones, i, j, variable, etiqueta, punto; double nval, m; posiciones = n_genes * long_poblacion; if (prob_mutacion > 0) { while (Mu_next < posiciones) { /* we determinate the chromosome and the gene */ i = Mu_next / n_genes; j = Mu_next % n_genes; m = Randomize.Rand(); /* the gene is of C1 */ if (j < base_datos.n_variables) { /* if I'm in the fisrt label */ if ( (m < 0.5 && (New[i].Gene[j] != (double) base_datos.n_etiquetas[j] - 1)) || New[i].Gene[j] == 0.0) { nval = New[i].Gene[j] + 1.0; } else { nval = New[i].Gene[j] - 1.0; } /* we update the membership function */ variable = j; etiqueta = (int) nval; New[i].Gene[base_datos.n_variables + 3 * variable] = base_datos.BaseDatos[variable][etiqueta].x0; New[i].Gene[base_datos.n_variables + 3 * variable + 1] = base_datos.BaseDatos[variable][etiqueta].x1; New[i].Gene[base_datos.n_variables + 3 * variable + 2] = base_datos.BaseDatos[variable][etiqueta].x3; } /* else the gene is of C2 */ else { /* we calculate the variable and label of the gene */ variable = (int) (j - base_datos.n_variables) / 3; etiqueta = (int) New[i].Gene[variable]; punto = (j - base_datos.n_variables) % 3; /* we mutate the gene */ if (m < 0.5) { nval = New[i].Gene[j] + delta(Gen, base_datos.intervalos[variable][etiqueta][punto].max - New[i].Gene[j], n_generaciones); } else { nval = New[i].Gene[j] - delta(Gen, New[i].Gene[j] - base_datos.intervalos[variable][etiqueta][punto].min, n_generaciones); } } New[i].Gene[j] = nval; New[i].n_e = 1; /* we calculate the next position */ if (prob_mutacion < 1) { m = Randomize.Rand(); Mu_next += (int) (Math.log(m) / Math.log(1.0 - prob_mutacion)); Mu_next++; } else { Mu_next += 1; } } Mu_next -= posiciones; } }
Example 13
Source File: AG_Tun.java From KEEL with GNU General Public License v3.0 | 4 votes |
/** Mutation Non Uniform */ public void Mutacion_No_Uniforme(long Gen, long n_generaciones) { int posiciones, i, j; double nval, m; posiciones = n_genes * long_poblacion; if (prob_mutacion > 0) { while (Mu_next < posiciones) { /* we determinate the chromosome and the gene */ i = Mu_next / n_genes; j = Mu_next % n_genes; /* we mutate the gene */ if (Randomize.Rand() < 0.5) { nval = New[i].Gene[j] + delta(Gen, intervalos[j].max - New[i].Gene[j], n_generaciones); } else { nval = New[i].Gene[j] - delta(Gen, New[i].Gene[j] - intervalos[j].min, n_generaciones); } New[i].Gene[j] = nval; New[i].n_e = 1; /* we calculate the next position */ if (prob_mutacion < 1) { m = Randomize.Rand(); Mu_next += (int) (Math.log(m) / Math.log(1.0 - prob_mutacion)); Mu_next++; } else { Mu_next += 1; } } Mu_next -= posiciones; } }
Example 14
Source File: SpecialMathFunction.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 4 votes |
public static double atanh(double x) throws ArithmeticException { if ((x > 1.0) || (x < -1.0)) { throw new ArithmeticException("range exception"); } return 0.5 * Math.log((1.0 + x) / (1.0 - x)); }
Example 15
Source File: Utils.java From KEEL with GNU General Public License v3.0 | 2 votes |
/** * Returns the logarithm of a for base 2. * * @param a a double * @return the logarithm for base 2 */ public static /*@pure@*/ double log2(double a) { return Math.log(a) / log2; }
Example 16
Source File: Utils.java From KEEL with GNU General Public License v3.0 | 2 votes |
/** * Returns the logarithm of a for base 2. * * @param a a double * @return the logarithm for base 2 */ public static /*@pure@*/ double log2(double a) { return Math.log(a) / log2; }
Example 17
Source File: M5StaticUtils.java From KEEL with GNU General Public License v3.0 | 2 votes |
/** * Returns the logarithm of a for base 2. * * @param a a double * @return the log2 of a. */ public static double log2(double a) { return Math.log(a) / log2; }
Example 18
Source File: Statistics.java From systemsgenetics with GNU General Public License v3.0 | 2 votes |
/** * Calculate hyperbolic Tangent of value (from https://github.com/maths/dragmath/blob/master/lib/jep/src/org/nfunk/jep/function/ArcTanH.java) * * @param x Value to calculate atanh for */ private static double atanh(double x){ return Math.log((1+x)/(1-x))/2; }
Example 19
Source File: SystemFunctions.java From incubator-retired-mrql with Apache License 2.0 | votes |
public static MR_double log ( MR_double n ) { return new MR_double(Math.log(n.get())); }
Example 20
Source File: SystemFunctions.java From incubator-retired-mrql with Apache License 2.0 | votes |
public static MR_float log ( MR_float n ) { return new MR_float(Math.log(n.get())); }