0

I have two matrixesthat belongs gaussian distribtion.The size are 3x3. Now, I want to estimate up and down threshold of their matrixes. I denote mean and standard deviation of each matrix is μ1;μ2 and σ1;σ2. The high and low threshold are

T_hight=(μ1+μ2)./2+k1∗(σ1+σ2)./2

T_low=(μ1+μ2)./2-k2∗(σ1+σ2)./2

where k1,k2 is const

My question is "Is my formula correct? Because this is gaussian distribution, so k1=k2,Right? And this is my code. Could you check have me"

μ1=mean(v1(:));first matrix 
σ1=std2(v1(:));
μ2=mean(v2(:));second matrix 
σ2=std2(v2(:));
k1=k2=1; 
T_hight=(μ1+μ2)./2+k1∗(σ1+σ2)./2;
T_low=(μ1+μ2)./2-k2∗(σ1+σ2)./2;
user3336190
  • 233
  • 1
  • 6
  • 22
  • I'm not quite clear what you are doing. What is k1, k2 and what do you mean by "up and down threshold"? Are you adding the matrices? If so have a look at [Sum_of_normally_distributed_random_variables](https://en.wikipedia.org/wiki/Sum_of_normally_distributed_random_variables) the resulting sd should be `sqrt(σ1^2+σ2^2)`. – Salix alba Apr 02 '14 at 06:35
  • k1 and k2 is const. They are weight factor. T_high and T_low are low and high threshold that I need. I not sure my formula is correct or not? That is first question. And your reference is only sum of two normal distributions. My distribution is mean of two normal distribtions. I think they are difference – user3336190 Apr 02 '14 at 07:11
  • 1
    The mean will just be half the sum so it is `(μ1+μ2)./2 +/- k1∗(sqrt(σ1^2+σ2^2))./2` – Salix alba Apr 02 '14 at 07:35

1 Answers1

1

In the formula you are using, the joint standard deviation is wrong.it should be

T_high=(μ1+μ2)./2+k1∗sqrt((σ1^2+σ2^2)/2);
T_low=(μ1+μ2)./2-k2∗sqrt((σ1^2+σ2^2)/2);

As you treat all 18 pixels as belonging to the same distribution, why not use the following

v=[v1(:);v2(:)];
μ=mean(v); 
σ=std(v);
k1=k2=1; 
T_high=μ+k1*σ;
T_low=μ-k2∗σ1;
Ophir Gvirtzer
  • 604
  • 4
  • 8
  • Thank you. I am wrong when use std2. Your way is good but how about if my maxtrix is large dimension. Can it work? – user3336190 Apr 02 '14 at 09:30
  • std2 is meant for 2-d matrices, for vector it is the same as std. So it is Ok to write std2(v1(:)), but it is more idiomatic to write std(v1(:)) or std2(v1) – Ophir Gvirtzer Apr 02 '14 at 09:47
  • If your data is a big matrix of logical, 8-bit integer of 16-bit integer, you may benefit in speed from using std2. Otherwise, std2 just calls std. – Ophir Gvirtzer Apr 02 '14 at 09:51