63 votes
Accepted

Why is generating 8 random bits uniform on (0, 255)?

TL;DR: The sharp contrast between the bits and coins is that in the case of the coins, you're ignoring the order of the outcomes. HHHHTTTT is treated as the same as TTTTHHHH (both have 4 heads and 4 ...
Sycorax's user avatar
  • 90.3k
58 votes
Accepted

Is there a plateau-shaped distribution?

You may be looking for distribution known under the names of generalized normal (version 1), Subbotin distribution, or exponential power distribution. It is parametrized by location $\mu$, scale $\...
55 votes

Why is the mean of the natural log of a uniform distribution (between 0 and 1) different from the natural log of 0.5?

This is another illustration of Jensen's inequality $$\mathbb E[\log X] < \log \mathbb E[X]$$ (since the function $x\mapsto \log(x)$ is strictly concave] and of the more general (anti-)property ...
Xi'an's user avatar
  • 104k
54 votes
Accepted

Why is the mean of the natural log of a uniform distribution (between 0 and 1) different from the natural log of 0.5?

Consider two values symmetrically placed around $0.5$ - like $0.4$ and $0.6$ or $0.25$ and $0.75$. Their logs are not symmetric around $\log(0.5)$. $\log(0.5-\epsilon)$ is further from $\log(0.5)$ ...
Glen_b's user avatar
  • 281k
51 votes
Accepted

Brain-teaser: What is the expected length of an iid sequence that is monotonically increasing when drawn from a uniform [0,1] distribution?

Here are some general hints on solving this question: You have a sequence of continuous IID random variables which means they are exchangeable. What does this imply about the probability of getting a ...
Ben's user avatar
  • 123k
40 votes

Is there an explanation for why there are so many natural phenomena that follow normal distribution?

Let me start by denying the premise. Robert Geary probably didn't overstate the case when he said (in 1947) "...normality is a myth; there never was, and never will be, a normal distribution.&...
Glen_b's user avatar
  • 281k
39 votes
Accepted

From uniform distribution to exponential distribution and vice-versa

It is not the case that exponentiating a uniform random variable gives an exponential, nor does taking the log of an exponential random variable yield a uniform. Let $U$ be uniform on $(0,1)$ and let ...
Glen_b's user avatar
  • 281k
39 votes
Accepted

Are differences between uniformly distributed numbers uniformly distributed?

No it is not uniform You can count the $36$ equally likely possibilities for the absolute differences ...
Henry's user avatar
  • 38.6k
31 votes
Accepted

R: Problem with runif: generated number repeats (more often than expected) after less than 100 000 steps

The documentation of R on random number generation has a few sentences at its end, that confirm your expectation of 32-bit integers being used and might explain what you are observing: Do not rely ...
L_W's user avatar
  • 451
26 votes
Accepted

Generating random points uniformly on a disk

The problem is due to the fact that the radius is not uniformly distributed. Namely, if $(X,Y)$ is uniformly distributed over $$\left\{ (x,y);\ x^2+y^2\le 1\right\}$$ then the (polar coordinates) ...
Xi'an's user avatar
  • 104k
22 votes

Why is Entropy maximised when the probability distribution is uniform?

Entropy in physics and information theory are not unrelated. They're more different than the name suggests, yet there's clearly a link between. The purpose of entropy metric is to measure the amount ...
Aksakal's user avatar
  • 60.9k
22 votes

Is there an explanation for why there are so many natural phenomena that follow normal distribution?

There is a famous saying by Gabriel Lippmann (physicist, Nobel laureate), as told by Poincaré: [The normal distribution] cannot be obtained by rigorous deductions. Several of its putative proofs ...
amoeba's user avatar
  • 104k
22 votes

Are differences between uniformly distributed numbers uniformly distributed?

Using only the most basic axioms about probabilities and real numbers, one can prove a much stronger statement: The difference of any two independent, identically distributed nonconstant random ...
whuber's user avatar
  • 321k
21 votes

Is there a plateau-shaped distribution?

@StrongBad's comment is a really good suggestion. The sum of a uniform RV and gaussian RV can give you exactly what you're looking for if you pick the parameters right. And it actually has a ...
21 votes

A three dice roll question

Because the point to an interview question is to demonstrate your thinking, I want to emphasize two things: Finding a simple, clear, analysis using minimal calculation and straightforward notation. ...
whuber's user avatar
  • 321k
20 votes

From uniform distribution to exponential distribution and vice-versa

You almost have it back to front. You asked: "If $X$ has a uniform distribution, does it mean that $e^X$ follows an exponential distribution?" "Similarly, if $Y$ follows an exponential distribution,...
Henry's user avatar
  • 38.6k
20 votes
Accepted

Continuous random variables - probability of a kid arriving on time for school

As you suggested, $X$ and $Y$ can be described as two independent uniform random variables $X \sim \mathcal{U(375, 405)}$, $Y \sim \mathcal{U(30, 40)}$. We are interesting in finding $\mathbb{P}[X + Y ...
nonin's user avatar
  • 315
19 votes
Accepted

Why is the sum of probabilities in a continuous uniform distribution not infinity?

$f(x)$ describes the probability density rather than a probability mass in your example. In general, for continuous distributions the events—the things we get probabilities for—are ranges of values, ...
Alexis's user avatar
  • 29.7k
18 votes
Accepted

Are discrete random variables, with same domain and uniform probability, always independent?

It is simple to construct an example where both variables are marginally uniformly distributed, but they are not independent. The simplest example is to take $X \sim \text{U} \{ -1,0,1 \}$ and let $Y=...
Ben's user avatar
  • 123k
18 votes
Accepted

In Bayesian models, can you use Uniform(-inf, inf) as a prior?

On this forum, there are a lot of related questions and answers about flat priors, like the ones above. They are not uniform priors because they are not distributions but $\sigma$-finite measures (...
Xi'an's user avatar
  • 104k
17 votes

Why are p-values uniformly distributed under the null hypothesis?

Let $T$ denote the random variable with cumulative distribution function $F(t) \equiv \Pr(T<t)$ for all $t$. Assuming that $F$ is invertible we can derive distribution of the random p-value $P = F(...
jII's user avatar
  • 612
17 votes
Accepted

Why does the number of continuous uniform variables on (0,1) needed for their sum to exceed one have mean $e$?

First observation: $Y$ has a more pleasing CDF than PMF The probability mass function $p_Y(n)$ is the probability that $n$ is "only just enough" for the total to exceed unity, i.e. $X_1 + X_2 + \dots ...
Silverfish's user avatar
  • 23.2k
17 votes

Why is generating 8 random bits uniform on (0, 255)?

why does a sequence of 8 zeroes or 8 ones seem to be equally as likely as a sequence of 4 and 4, or 5 and 3, etc The aparent paradox can be summarized in two propositions, that might seem ...
leonbloy's user avatar
  • 1,458
17 votes
Accepted

Relation between independence and correlation of uniform random variables

Independent implies uncorrelated but the implication doesn't go the other way. Uncorrelated implies independence only under certain conditions. e.g. if you have a bivariate normal, it is the case that ...
Glen_b's user avatar
  • 281k
17 votes
Accepted

What distribution does the mean of a random sample from a Uniform distribution follow?

First, you might want to look at Wikipedia on Irwin-Hall distribution. Unless $n$ is very small $A = \bar X = \frac{1}{n}\sum_{i=1}^{n} X_i,$ where $X_i$ are independently $\mathsf{Unif}(\theta-.5,\...
BruceET's user avatar
  • 55.7k
17 votes

Generating random points uniformly on a disk

The simplest and least error-prone approach would be rejection sampling: generate uniformly distributed points in the square around your circle, and only keep those that are in the circle. ...
Stephan Kolassa's user avatar
16 votes

Is there a plateau-shaped distribution?

There's an infinite number of "plateau-shaped" distributions. Were you after something more specific than "in between the Gaussian and the uniform"? That's somewhat vague. Here's one easy one: you ...
16 votes

Uniform vs Beta(1,1) prior

They both are equivalent. $P(\theta) = { \Gamma(\alpha + \beta) \over \Gamma(\alpha)\Gamma(\beta)} \theta^{\alpha-1}(1-\theta)^{\beta-1}$ if $\alpha = \beta = 1$ $P(\theta) = { \Gamma(\alpha + \...
carlos's user avatar
  • 301
16 votes

R: Problem with runif: generated number repeats (more often than expected) after less than 100 000 steps

Just to emphasise the arithmetic of the $2^{32}$ point in terms of the number of potential distinct values: if you sample $10^5$ times from $2^{32}$ values with replacement, you would expect an ...
Henry's user avatar
  • 38.6k
15 votes
Accepted

Generating Data from Arbitrary Distribution

This is known as inverse transform sampling. The idea is well encapsulated in the following picture from Wikipedia: Note that the image of the cumulative distribution function (CDF) $F_X$ is the ...
Stephan Kolassa's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible