Skip to main content
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
  • 92.6k
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
  • 107k
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
  • 286k
52 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
  • 129k
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
  • 286k
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
  • 40.5k
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
27 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
  • 107k
23 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
  • 328k
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
  • 61.8k
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
  • 328k
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
  • 40.5k
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
  • 30.3k
18 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
  • 651
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
  • 129k
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
  • 107k
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

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
  • 311
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
  • 286k
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
  • 57k
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

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
  • 40.5k
15 votes

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

I think the answer as to "Why are p-values uniformly distributed under the null hypothesis?" has been sufficiently discussed from a mathematical perspective. What I thought is missing is a ...
Stefan's user avatar
  • 6,501
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
14 votes
Accepted

PDF of cosine of a uniform random variable

First note that $\cos$ is an even function; $\cos(-X)=\cos(X)$. Consequently it's the same as taking $\cos(W)$ where $W=|X|$ (or indeed you could work instead with $\cos(-W)$). Now $W$ is uniform on $[...
Glen_b's user avatar
  • 286k
14 votes

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

Write $X \sim U(15,45)$ and $Y \sim U(30,40)$, then can write what you are trying to solve for as $P(X+Y<60)$. I am using the starting time here as 6:00AM and therefore need the sum of time passed ...
dlnB's user avatar
  • 2,289
14 votes

What distribution to sample X from to get an uniform distribution in Y?

maybe i misunderstand your question, but why don't you sample from a uniform distribution and set X to the arccos of your samples? in R, this would be ...
schotti's user avatar
  • 521
13 votes

Why is the CDF of a sample uniformly distributed

Here's some intuition. Let's use a discrete example. Say after an exam the students' scores are $X = [10, 50, 60, 90]$. But you want the scores to be more even or uniform. $h(X) = [25, 50, 75, 100]$ ...
ztyreg's user avatar
  • 131
13 votes
Accepted

How is $\theta$, the polar coordinate, distributed when $(x,y) \sim U(-1,1) \times U(-1,1)$ vs. when $(x,y) \sim N(0,1)\times N(0,1)$?

You're referring to a transformation from a pair of independent variates $(X,Y)$ to the polar representation $(R,\theta)$ (radius and angle), and then looking at the marginal distribution of $\theta$. ...
Glen_b's user avatar
  • 286k

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