# Variance in set of different random variables

Imagine we have sample of values a_1, a_2,...a_n, with a_i value originating from a normal distribution with mean mu_i_a and variance var_i_a, thus each value is single realization of different random variable. Then we have another sample of values b_1,..b_n, with value b_i originating from a normal distribution with mean mu_i_b and variance var_i_b. How can we compare dispersion of first sample (that is, values a_i,...a_n) with dispersion of the other sample (that is, values b_1, ... b_n).

A practical example, which can be related to this situation, imagine that we have average yearly salary for each state in USA in 1990 (mean +/- SEM for each state) and the same in 2010. The question is, how to measure if the state-specific mean salaries became more or less dispersed across time. For example, some politicians take measure to decrease salary inhomogenity across USA states, how to quantify if their measures have been succesfull?

This is edited version of previous question, so to make the question more clear.

• Isn't the sample variance for each set of values what you want ? Commented Dec 1, 2023 at 15:36
• Imagine we measure average height of a person in each state of USA and for east state of EU. We would like to know if heights in USA are more or less dispersed than in EU. Notable, height in each individual state represents specific random variable. Or we compare dispersion aross USA states between 2 different years (such as 1900 and 2000). Commented Dec 1, 2023 at 15:42
• Is the question: How to measure dispersion of a random sample of independent, but not identically distributed variables? Commented Dec 1, 2023 at 15:46
• Yes, that is correct. Commented Dec 1, 2023 at 15:47
• If they are plausibly normally distributed, an F test might be what you want. Commented Dec 1, 2023 at 15:49

You said:

We would like to know if heights in USA are more or less dispersed than in EU

I take this to mean that you want to compare the variance of two samples. This can be done with an F test which tests whether the ratio of the variances of the two sample is equal to 1. For example, in R, we can create two samples, with different means, but the same variance:

N <- 100
set.seed(15)
sample1 <- rnorm(N, 1, 1)
sample2 <- rnorm(N, 2, 1)

var.test(sample1, sample2)


produces:

F test to compare two variances

data:  sample1 and sample2
F = 0.81734, num df = 99, denom df = 99, p-value = 0.3173
alternative hypothesis: true ratio of variances is not equal to 1
95 percent confidence interval:
0.5499379 1.2147528
sample estimates:
ratio of variances
0.8173363


so there is insufficient evidence to reject the null hypothesis that the variances are equal. Now we do the same simulation with different variances:

N <- 100
set.seed(15)
sample1 <- rnorm(N, 1, 1)
sample2 <- rnorm(N, 2, 2)

var.test(sample1, sample2)


which produces:

    F test to compare two variances

data:  sample1 and sample2
F = 0.20433, num df = 99, denom df = 99, p-value = 5.592e-14
alternative hypothesis: true ratio of variances is not equal to 1
95 percent confidence interval:
0.1374845 0.3036882
sample estimates:
ratio of variances
0.2043341


So here we would reject the null hypothesis that the variances are equal.

• In this example the values are generated in such a way that they are identically distributed (within sample). But I am interested in situation, where such an assumption can not be made (two samples of outcomes of many different random variables rather than samples of outcomes of two random variables). Commented Dec 1, 2023 at 16:32
• If each random variable has a different distribution, it gets delicate to have a common measure of variability. Commented Dec 1, 2023 at 16:35
• For example, heights in Netherlands come from different distribution than heights in Portugal. Commented Dec 1, 2023 at 16:38
• I have modified my question to reduce ambiguity. Commented Dec 1, 2023 at 16:49