# Random variable of random variable [closed]

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=rand(1,N).*20+10;%average
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
list_drawn_value=randn(1,N).*gauss_list_sd+gauss_list_mean;
else% slow
list_drawn_value=zeros(1,N);
for i=1:N
list_drawn_value(i) = normrnd(gauss_list_mean(i),gauss_list_sd(i));
end
end

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));

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).