MATLAB: Find the variance of x/y

divisionvariance

I am new to Matlab. My question sounds to be very simple, however, I cannot make it work in Matlab. Basically, I would like to find the variance of x/y. Each x and y group has 500 single numbers. Please help to make it happen in Matlab. Thanks in advance.

Best Answer

I've added this as a second answer, since it answers the question as modified by the OP.
Essentially, you have two discrete sets of values. You are asking to compute the POPULATION variance of the ratio of the members of those discrete sets, thus all possible combinations, assuming they are equally likely to arise. I emphasized the word "population" for a reason, since you need to be careful in how you compute a population variance. The difference is in the divisor inside the variance code. That difference can be quite significant for small sizes.
x=[1 1 2];
y=[2 4 5];
[xx,yy] = meshgrid(x,y);
var(xx(:)./yy(:),1)
ans =
0.056728
So note the 1 as the second argument to var there. That indicates to var to divide by N, not N-1 in the variance computation. We divide by N when this is a complete population, N-1 when it is a sample variance.