Questions tagged [entropy]

Entropy is a measure of the uncertainty in a random variable.

The term usually refers to the Shannon entropy, which quantifies the expected value of the information contained in a message. Entropy is typically measured in bits, nats, or bans. Shannon entropy is the average unpredictability in a random variable, which is equivalent to its information content.

596 questions
188
votes
17 answers

How to deal with a slow SecureRandom generator?

If you want a cryptographically strong random numbers in Java, you use SecureRandom. Unfortunately, SecureRandom can be very slow. If it uses /dev/random on Linux, it can block waiting for sufficient entropy to build up. How do you avoid the…
David G
  • 6,249
  • 4
  • 33
  • 31
155
votes
5 answers

How to generate random SHA1 hash to use as ID in node.js?

I am using this line to generate a sha1 id for node.js: crypto.createHash('sha1').digest('hex'); The problem is that it's returning the same id every time. Is it possible to have it generate a random id each time so I can use it as a database…
ajsie
  • 77,632
  • 106
  • 276
  • 381
82
votes
12 answers

How to calculate the entropy of a file?

How to calculate the entropy of a file? (Or let's just say a bunch of bytes) I have an idea, but I'm not sure that it's mathematically correct. My idea is the following: Create an array of 256 integers (all zeros). Traverse through the file and for…
ivan_ivanovich_ivanoff
  • 19,113
  • 27
  • 81
  • 100
72
votes
14 answers

Fastest way to compute entropy in Python

In my project I need to compute the entropy of 0-1 vectors many times. Here's my code: def entropy(labels): """ Computes entropy of 0-1 vector. """ n_labels = len(labels) if n_labels <= 1: return 0 counts =…
blueSurfer
  • 5,651
  • 13
  • 42
  • 63
70
votes
15 answers

PGP: Not enough random bytes available. Please do some other work to give the OS a chance to collect more entropy

Setup : Ubuntu Server on Virtual Machine with 6 cores and 3GB of RAM. when I am trying to generate a asymmetric key pair via GPG like this gpg --gen-key . I get the following error : Not enough random bytes available. Please do some other work to…
user1524529
  • 897
  • 3
  • 10
  • 12
69
votes
16 answers

What is the computer science definition of entropy?

I've recently started a course on data compression at my university. However, I find the use of the term "entropy" as it applies to computer science rather ambiguous. As far as I can tell, it roughly translates to the "randomness" of a system or…
fluffels
  • 4,051
  • 7
  • 35
  • 53
55
votes
7 answers

How do I compute the approximate entropy of a bit string?

Is there a standard way to do this? Googling -- "approximate entropy" bits -- uncovers multiple academic papers but I'd like to just find a chunk of pseudocode defining the approximate entropy for a given bit string of arbitrary length. (In case…
dreeves
  • 26,430
  • 45
  • 154
  • 229
42
votes
4 answers

How does the kernel entropy pool work?

I'm using /dev/urandom to generate random data for my programs. I learned that /dev/random can be empty because, unlike /dev/urandom, it doesn't use SHA when there are not enough bytes generated. /dev/random uses "the kernel entropy pool".…
Antoninarto
  • 701
  • 1
  • 6
  • 12
30
votes
1 answer

Mutual information and joint entropy of two images - MATLAB

I have two black and white images and I need to calculate the mutual information. Image 1 = X Image 2 = Y I know that the mutual information can be defined as: MI = entropy(X) + entropy(Y) - JointEntropy(X,Y) MATLAB already has built-in…
Jorge
  • 400
  • 1
  • 5
  • 15
25
votes
3 answers

How good is SecRandomCopyBytes?

I'm principally interested in the implementation of SecRandomCopyBytes on iOS, if it differs from the OS X implementation. (I would presume that it does, since a mobile device has more and more readily available sources of entropy than a desktop…
James
  • 24,676
  • 13
  • 84
  • 130
19
votes
3 answers

Shuffling a poker deck in JavaScript with window.crypto.getRandomValues

A poker deck has 52 cards and thus 52! or roughly 2^226 possible permutations. Now I want to shuffle such a deck of cards perfectly, with truly random results and a uniform distribution, so that you can reach every single one of those possible…
caw
  • 30,999
  • 61
  • 181
  • 291
17
votes
2 answers

What is the entropy of an image and how is it calculated?

I have learnt that it is the randomness of the pixels. But please help with how this randomness is being calculated mathematically. And also how different images will have different entropy.
gag123
  • 357
  • 1
  • 2
  • 8
17
votes
3 answers

Help with the calculation (and usefulness) of password entropy

This is a two part question: Part 1 First, dealing with calculating the entropy of a password in PHP. I have been unable to find any code examples that are empirically sound and would really like some help in finding the 'right' way to calculate a…
Shane
  • 16,779
  • 5
  • 27
  • 46
16
votes
3 answers

How do I calculate the entropy of a graph?

I have a set of randomly generated formal graphs, and I would like to calculate the entropy of each one. The same question in different words: I have several networks, and want to calculate the information content of each one. Here are two sources…
16
votes
2 answers

Calculating entropy from GLCM of an image

I am using skimage library for most of image analysis work. I have an RGB image and I intend to extract texture features like entropy, energy, homogeneity and contrast from the image. Below are the steps that I am performing: from skimage import…
Sreejith Menon
  • 1,057
  • 1
  • 18
  • 27
1
2 3
39 40