# How to get p-value for indirectly generated random variables?

This is an extension of a question I had previously asked. If the answer is a simple text-book question then feel free to reference it.

The problem started out as a need to compare two experimental data sets, one demonstrating ideal conditions, and the other, demonstrating what happens when a specific event is triggered during the experiments.

I end up with two sets of results, of non-gaussian distribution:

Sample 1a (ideal): 32 data points $$\mu_{1a} = 0.5505, \sigma^2_{1a}= 4.9047*10^{-5}$$

Sample 1b (non-ideal): 31 data points $$\mu_{1b} = 0.5314*10^3, \sigma^2_{1b}= 5.4851*10^{-5}$$

While the difference is small, it is significant, and my interest revolves around that difference in mean.

When I change the parameters of the experiment, I get another set of results:

Sample 2a: 34 data points $$\mu_{2a} = 0.5395, \sigma^2_{2a}= 2.3220*10^{-5}$$

Sample 2b: 33 data points $$\mu_{2b} = 0.5271*10^3, \sigma^2_{2b}= 2.0283*10^{-5}$$

What I need to do is demonstrate that Sample 2, provides a different mean difference then Sample 1, and I want to provide the p-value for the associated null-hypothesis. At this point, I don't mind assuming the sample difference is Gaussian (although I wouldn't for inter-sample analysis).

Using Matlab, I initially planned on doing the following:

normcdf(0,abs(sol.meanLoss -  comp.meanLoss),sqrt(sol.ste^2 + comp.ste^2));


which calculates the area under the curve of a Gaussian distribution ( parameters as mean: mean difference between Sample 1 and 2 ( $(\mu_{1a}-\mu_{1b})- (\mu_{2a} -\mu_{2b})$), and std as the square root of the sum of the squares of the standard error of each sample ) from -Inf to 0.

I'm not sure my answer is correct and I'm don't mind having it torn apart, but I would need something else. If the t-test is to be used, how ought I combine the Samples?

Edit:

note that I have calculated the standard error as

$$ste_1 = \sqrt{ \sigma^2_{1a}/N_{1a}+\sigma^2_{1b}/N_{1b}}$$

-
 You haven't adjusted the standard errors for sample size - the standard error of $\mu_{1a}$ is $\sigma_{1a}/\sqrt{n_{1a}}$, and similarly for the standard errors of $\mu_{1b}$, $\mu_{2a}$, and $\mu_{2b}$. After these calculations, you can then do the square root of the sum of the squared standard errors thing. – jbowman Jul 9 '12 at 16:09 @jbowman (see edit) is that what you meant? or do you mean that I need to change it after that? – Rasman Jul 9 '12 at 16:20 That's right. Did you have it that way to start? If so, I'll delete my irrelevant comment. – jbowman Jul 9 '12 at 16:27 @jbowman. It was a necessary clarification that I should have added. Your comment is appreciated. – Rasman Jul 9 '12 at 16:36 Thanks! Anyway, your calculations look correct to me now. – jbowman Jul 9 '12 at 18:40