Example usage for java.lang Math log10

List of usage examples for java.lang Math log10

Introduction

In this page you can find the example usage for java.lang Math log10.

Prototype

@HotSpotIntrinsicCandidate
public static double log10(double a) 

Source Link

Document

Returns the base 10 logarithm of a double value.

Usage

From source file:cpsControllers.ConversionController.java

/**
 * Stosunek sygna - szum (SNR, ang. <i>Signal to Noise Ratio</i>)
 *     /*from www  . jav  a2s .c  o m*/
 * @param punktyY
* @return
 */
public double obl_SNR(ArrayList<Double> punktyY, ArrayList<Double> _doPorownania) {
    double wynik = 0;
    try {
        if (!punktyY.isEmpty() && !_doPorownania.isEmpty()) {
            double licznik = 0, mianownik = 0;
            for (int i = 0; i < _doPorownania.size(); i++) {
                licznik = licznik + (punktyY.get(i) * punktyY.get(i));
            }
            for (int i = 0; i < _doPorownania.size(); i++) {
                mianownik = mianownik
                        + (punktyY.get(i) - _doPorownania.get(i)) * (punktyY.get(i) - _doPorownania.get(i));
            }
            wynik = licznik / mianownik;
            wynik = 10.0D * Math.log10(wynik);
        } else {
            if (punktyY.isEmpty()) {
                JOptionPane.showMessageDialog(null, "Brak sygnau.", "Bd", JOptionPane.ERROR_MESSAGE);
            } else if (_doPorownania.isEmpty()) {
                JOptionPane.showMessageDialog(null, "Brak konwersji sygnau.", "Bd",
                        JOptionPane.ERROR_MESSAGE);
            }
        }
    } catch (Exception exc_MSE) {
        //            JOptionPane.showMessageDialog(null, "Nie mona obliczy:\n" + exc_MSE.getMessage(),
        //                    "Bd", JOptionPane.ERROR_MESSAGE);
        wynik = -1;
    }

    System.out.println("SNR = " + wynik);
    return wynik;
}

From source file:bemap.realTimeWindow.java

private double convertNOPPM(int no2) {
    return Math.pow(10, (0.809 + 1.031 * Math.log10((1024.0 - no2) / no2)));
}

From source file:it.proximacentauri.ienergy.da.dao.impl.ConfortDaoImpl.java

@Override
public Double computeResult(Indicator indicator, Date start, Date end) {
    log.info("compute the result of indicator {} from date {} to date {}", indicator.getName(), start, end);
    Query query = null;//from  ww w .  j  a  va2s  .c  om

    switch (indicator.getFunction()) {
    case AVG:
        query = em.createQuery(
                "SELECT AVG(v.value) FROM Vote as v JOIN v.indicator as i where i.name = :name and v.time >= :start and v.time <= :end");
        break;
    case LOGABSSUM:
        query = em.createQuery(
                "SELECT SUM(v.value) FROM Vote as v JOIN v.indicator as i where i.name = :name and v.time >= :start and v.time <= :end");
        break;
    case LOGSUM:
    case SUM:
    default:
        query = em.createQuery(
                "SELECT SUM(v.value) FROM Vote as v JOIN v.indicator as i where i.name = :name and v.time >= :start and v.time <= :end");
        break;

    }
    query.setParameter("name", indicator.getName());
    query.setParameter("start", start);
    query.setParameter("end", end);

    final Object object = query.getResultList().get(0);
    Double result = null;
    if (object == null)
        return null;
    if (object instanceof Long) {
        result = new Double(object.toString());
    } else {
        result = (Double) object;
    }

    // post selection computing
    log.debug("result of database group by is {}", result);

    switch (indicator.getFunction()) {
    case LOGABSSUM:
        if (result.doubleValue() > 0.0)
            return Math.log10(result);
        if (result.doubleValue() < 0.0)
            return -Math.log10(-result);
        return result;

    case LOGSUM:
        if (result.doubleValue() == 0.0)
            return result;
        return Math.log10(result);
    default:
        return result;

    }
}

From source file:com.bmwcarit.barefoot.markov.StateTest.java

@Test
public void TestStateJSON() throws JSONException {
    Map<Integer, MockElem> elements = new HashMap<>();

    StateMemory<MockElem, StateTransition, Sample> state = new StateMemory<>();

    {//from   w w  w  .ja  v a  2s. c  om
        JSONObject json = state.toJSON();
        state = new StateMemory<>(json, new MockFactory());
    }

    elements.put(0, new MockElem(0, Math.log10(0.3), 0.3, null));
    elements.put(1, new MockElem(1, Math.log10(0.2), 0.2, null));
    elements.put(2, new MockElem(2, Math.log10(0.5), 0.5, null));

    state.update(new HashSet<>(Arrays.asList(elements.get(0), elements.get(1), elements.get(2))),
            new Sample(0));

    {
        JSONObject json = state.toJSON();
        state = new StateMemory<>(json, new MockFactory());

        elements.clear();

        for (MockElem element : state.vector()) {
            elements.put(element.numid(), element);
        }
    }

    elements.put(3, new MockElem(3, Math.log10(0.3), 0.3, elements.get(1)));
    elements.put(4, new MockElem(4, Math.log10(0.2), 0.2, elements.get(1)));
    elements.put(5, new MockElem(5, Math.log10(0.4), 0.4, elements.get(2)));
    elements.put(6, new MockElem(6, Math.log10(0.1), 0.1, elements.get(2)));

    state.update(
            new HashSet<>(Arrays.asList(elements.get(3), elements.get(4), elements.get(5), elements.get(6))),
            new Sample(1));

    {
        JSONObject json = state.toJSON();
        state = new StateMemory<>(json, new MockFactory());

        elements.clear();

        for (MockElem element : state.vector()) {
            elements.put(element.numid(), element);
        }
    }

    elements.put(7, new MockElem(7, Math.log10(0.3), 0.3, elements.get(5)));
    elements.put(8, new MockElem(8, Math.log10(0.2), 0.2, elements.get(5)));
    elements.put(9, new MockElem(9, Math.log10(0.4), 0.4, elements.get(6)));
    elements.put(10, new MockElem(10, Math.log10(0.1), 0.1, elements.get(6)));

    state.update(
            new HashSet<>(Arrays.asList(elements.get(7), elements.get(8), elements.get(9), elements.get(10))),
            new Sample(2));

    {
        JSONObject json = state.toJSON();
        state = new StateMemory<>(json, new MockFactory());

        elements.clear();

        for (MockElem element : state.vector()) {
            elements.put(element.numid(), element);
        }
    }

    elements.put(11, new MockElem(11, Math.log10(0.3), 0.3, null));
    elements.put(12, new MockElem(12, Math.log10(0.2), 0.2, null));
    elements.put(13, new MockElem(13, Math.log10(0.4), 0.4, null));
    elements.put(14, new MockElem(14, Math.log10(0.1), 0.1, null));

    state.update(
            new HashSet<>(
                    Arrays.asList(elements.get(11), elements.get(12), elements.get(13), elements.get(14))),
            new Sample(3));

    state.update(new HashSet<MockElem>(), new Sample(4));

    {
        JSONObject json = state.toJSON();
        StateMemory<MockElem, StateTransition, Sample> state2 = new StateMemory<>(json, new MockFactory());

        assertEquals(state.size(), state2.size());
        assertEquals(4, state2.size());
        assertEquals(state.estimate().numid(), state2.estimate().numid());
        assertEquals(13, state2.estimate().numid());
    }
}

From source file:bemap.realTimeWindow.java

private double convertCOPPM(int co) {
    return Math.pow(10, (0.64 - 1.21 * Math.log10((1024.0 - co) / co)));
}

From source file:org.schedoscope.metascope.util.HTMLUtil.java

public String getSize(long size) {
    if (size <= 0) {
        return "0";
    }//www.  j av a  2 s.  c o  m
    final String[] units = new String[] { "B", "kB", "MB", "GB", "TB" };
    int digitGroups = (int) (Math.log10(size) / Math.log10(1024));
    return new DecimalFormat("#,##0.#").format(size / Math.pow(1024, digitGroups)) + " " + units[digitGroups];
}

From source file:com.ethercamp.harmony.web.controller.WebSocketController.java

private String readableFileSize(long size) {
    if (size <= 0)
        return "0";
    final String[] units = new String[] { "B", "kB", "MB", "GB", "TB" };
    int digitGroups = (int) (Math.log10(size) / Math.log10(1024));
    return new DecimalFormat("#,##0.#").format(size / Math.pow(1024, digitGroups)) + " " + units[digitGroups];
}

From source file:chatbot.Chatbot.java

/** ************************************************************************************************
 * inverse document frequency = log of number of documents divided by
 * number of documents in which a term appears.
 * Note that if the query is included as index -1 then it will
 * get processed too. Put the results into
 * HashMap<String,Float> idf/*from w  ww . j  av a2 s .  c om*/
 */
private void calcIDF(int docCount) {

    idf.putAll(docfreq.keySet().stream().collect(
            Collectors.toMap((t) -> t, t -> ((float) Math.log10((float) docCount / (float) docfreq.get(t))))));
}

From source file:org.efaps.db.store.VFSStoreResource.java

/**
 * Method called to initialize this StoreResource.
 * @param _instance     Instance of the object this StoreResource is wanted
 *                      for//  w  ww. j av  a 2 s  .  c  o  m
 * @param _store        Store this resource belongs to
 * @throws EFapsException on error
 * @see Resource#initialize(Instance, Map, Compress)
 */
@Override
public void initialize(final Instance _instance, final Store _store) throws EFapsException {
    super.initialize(_instance, _store);

    final StringBuilder fileNameTmp = new StringBuilder();

    final String useTypeIdStr = getStore().getResourceProperties().get(VFSStoreResource.PROPERTY_USE_TYPE);
    if ("true".equalsIgnoreCase(useTypeIdStr)) {
        fileNameTmp.append(getInstance().getType().getId()).append("/");
    }

    final String numberSubDirsStr = getStore().getResourceProperties()
            .get(VFSStoreResource.PROPERTY_NUMBER_SUBDIRS);
    if (numberSubDirsStr != null) {
        final long numberSubDirs = Long.parseLong(numberSubDirsStr);
        final String pathFormat = "%0" + Math.round(Math.log10(numberSubDirs) + 0.5d) + "d";
        fileNameTmp.append(String.format(pathFormat, getInstance().getId() % numberSubDirs)).append("/");
    }
    fileNameTmp.append(getInstance().getType().getId()).append(".").append(getInstance().getId());
    this.storeFileName = fileNameTmp.toString();

    final String numberBackupStr = getStore().getResourceProperties()
            .get(VFSStoreResource.PROPERTY_NUMBER_BACKUP);
    if (numberBackupStr != null) {
        this.numberBackup = Integer.parseInt(numberBackupStr);
    }

    if (this.manager == null) {
        try {
            DefaultFileSystemManager tmpMan = null;
            if (getStore().getResourceProperties().containsKey(Store.PROPERTY_JNDINAME)) {
                final InitialContext initialContext = new InitialContext();
                final Context context = (Context) initialContext.lookup("java:comp/env");
                final NamingEnumeration<NameClassPair> nameEnum = context.list("");
                while (nameEnum.hasMoreElements()) {
                    final NameClassPair namePair = nameEnum.next();
                    if (namePair.getName()
                            .equals(getStore().getResourceProperties().get(Store.PROPERTY_JNDINAME))) {
                        tmpMan = (DefaultFileSystemManager) context
                                .lookup(getStore().getResourceProperties().get(Store.PROPERTY_JNDINAME));
                        break;
                    }
                }
            }
            if (tmpMan == null && this.manager == null) {
                this.manager = evaluateFileSystemManager();
            }
        } catch (final NamingException e) {
            throw new EFapsException(VFSStoreResource.class, "initialize.NamingException", e);
        }
    }
}

From source file:libra.core.kmersimilarity_m.KmerSimilarityMapper.java

@Override
protected void map(CompressedSequenceWritable key, KmerMatchResult value, Context context)
        throws IOException, InterruptedException {
    IntWritable[] valueArray = value.getVals();
    Path[] kmerIndexPathArray = value.getKmerIndexPath();

    // filter out empty values
    ArrayList<IntWritable> filteredValueArray = new ArrayList<IntWritable>();
    ArrayList<Path> filteredKmerIndexPathArray = new ArrayList<Path>();

    for (int i = 0; i < valueArray.length; i++) {
        if (valueArray[i] != null) {
            filteredValueArray.add(valueArray[i]);
            filteredKmerIndexPathArray.add(kmerIndexPathArray[i]);
        }//ww w . ja v a  2  s.c o  m
    }

    valueArray = null;
    kmerIndexPathArray = null;

    if (filteredValueArray.size() <= 1) {
        // skip
        return;
    }

    int[] fileid_arr = new int[filteredValueArray.size()];

    for (int i = 0; i < filteredValueArray.size(); i++) {
        int fileidInt = 0;
        String indexFilename = filteredKmerIndexPathArray.get(i).getName();
        Integer fileid = this.idCacheTable.get(indexFilename);
        if (fileid == null) {
            String fastaFilename = KmerIndexHelper.getFastaFileName(indexFilename);
            int id = this.fileMapping.getIDFromFastaFile(fastaFilename);
            this.idCacheTable.put(indexFilename, id);
            fileidInt = id;
        } else {
            fileidInt = fileid.intValue();
        }

        fileid_arr[i] = fileidInt;
    }

    // compute normal
    double[] normal = new double[this.valuesLen];
    for (int i = 0; i < this.valuesLen; i++) {
        normal[i] = 0;
    }

    for (int i = 0; i < filteredValueArray.size(); i++) {
        IntWritable arr = filteredValueArray.get(i);
        int freq = arr.get();
        double tf = 1 + Math.log10(freq);
        normal[fileid_arr[i]] = ((double) tf) / this.tfConsineNormBase[fileid_arr[i]];
    }

    accumulateScore(normal);

    this.reportCounter.increment(1);
}