This is confusing and difficut, but I hope it makes a sence. I am interested in kind of like Random variable of Random variable. This issue might've been mentioned below before.

The Probability distribution of Random variable of Random variable

Let me clarify.
Random variable of Random variable (RVoRV) here is not
add/subtract operation of two random variables.
It is about a single measurement of random variables, where each variable actually came from another random variable.
or I should say, list of values for a distribution , where each value comes from its own parent-distribution. but measurement was done only once

Is there any material or anything that mentioned this issue?

As an example, I made matlab code below.
It creates N different gaussian distributions with their N standard deviations chosen uniform randomly with some variance. Then it draw a single value from each of N different gaussians as random variable, making a list of N values.
now what is the standard deviation of this N value list?
As i run this code over and over, sd stays near a certain value. Any equation for that?
Thank you.


clear all; close all; clc;

N=100000;% number of gaussian distributions

% mean for N gaussians -------------
gauss_list_mean=repmat(0,1,N);%average same value

% sigma for N gaussians -------------
gauss_list_sd=rand(1,N).*20;%standard deviation
%gauss_list_sd=repmat(15,1,N);%standard deviation same value

% draw a value from each of N different gaussian distributions
if 0% fast version
else% slow
 for i=1:N
  list_drawn_value(i) = normrnd(gauss_list_mean(i),gauss_list_sd(i));

sd_value=std(list_drawn_value);%Get standard deviation of values from N different gaussians

fprintf(' sd of drawn values from %d Gaussians =%g \n',N,sd_value);

fprintf('mean(gauss_list_sd)=%g std(gauss_list_sd)=%g\n',mean(gauss_list_sd),std(gauss_list_sd));


1 Answer 1


Your question will surely be closed, because it's not on topic for this site.

Nevertheless ... notice that the (pseudo-)random samples created by your code, say $X_1,...,X_N$, are such that each $X_i = \mu_i + \sigma_i Z_i$, where $\mu_i = 10 + 20\,U_i$ and $\sigma_i = 20\,U_i'$, with $Z_i\sim \text{Gaussian}(0,1)$, and $U_i,U_i'\sim \text{Uniform(0,1)}$, and all are mutually independent.

Thus, the $X_i$ are i.i.d. with $X_i = 10 + 20\,U_i + 20\,U_i'\,Z_i$, and their sample variance is therefore a consistent estimator of $V(X_i)= 20^2V(U_i) + 20^2\,V(U_i'\,Z_i)$.

Now $V(U_i)=\frac{1}{12}$ and $V(U_i'\,Z_i)=E({U_i'}^2\,Z_i^2)-[E(U_i'\,Z_i)]^2 = E({U_i'}^2)\,E(Z_i^2)=\frac{1}{3}\cdot1$, so you should be seeing a sample standard deviation near $20\sqrt{\frac{5}{12}}$ (if I haven't made any arithmetic errors).

  • $\begingroup$ Sorry for off topic and thank you for the answer. It is a great help, now i feel i know how to solve all other problems like this one as well. Greatly appreciated. $\endgroup$
    – JimSD
    Jul 28, 2016 at 6:22

Not the answer you're looking for? Browse other questions tagged or ask your own question.