Java Entropy Calculate longPseudoEntropy()

Here you can find the source of longPseudoEntropy()

Description

Not suited for cryptographic usage.

License

Apache License

Return

A pseudo-entropic uniform long value.

Declaration

static long longPseudoEntropy() 

Method Source Code

//package com.java2s;
/*/*from  w  w  w  .  j  a va 2 s .  c o m*/
 * Copyright 2014 Jeff Hain
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import java.util.Random;

public class Main {
    /**
     * Not suited for cryptographic usage.
     * 
     * @return A pseudo-entropic uniform long value.
     */
    static long longPseudoEntropy() {
        /*
         * Using pseudo-entropy from same pseudo-entropy source than Random.
         * Using a copy-pasted version of JDK's mechanics might cause both
         * pseudo-entropy sources to be effectively correlated if used in
         * parallel (even though we don't use the actual seed, since it's not
         * available, but nextLong()).
         * NB: Using ThreadLocalRandom (Java7) might be a bad idea here,
         * since the value would be obviously correlated with current TLR's
         * numbers sequence.
         */
        return new Random().nextLong();
    }
}

Related

  1. entropy(double[] vals)
  2. entropy(int hist[])
  3. entropy(int numBins, double[] _f)
  4. entropy(int total, double[] data)
  5. entropy(int[] histogram)