z scores without the stats toolbox

  • Follow


Hi, 

Im trying to calculate z scores in matlab (I don't have the statistics toolbox)
I have a matrix of 20 x 40 called 'nt'
I have used the following code

nt_s = std(nt(:)); 
nt_mu = mean(mean(nt));  
x=nt-nt_mu; 
nt_z=x./nt_s; 

but this only gives me z scores for each column, when I actually want a zscore for each individual score in the matrix. 
Any ideas?

Also I would like an easy way of finding what values in the z score matrix are > +3 and < -3

I only know how to type Z = nt_Z > 3 and Z = nt_z < -3 separately. 
These are probably very easy questions, but Im very new to matlab

Thanks for your help
0
Reply Tracey 3/6/2010 2:54:03 PM

Tracey wrote:
> Hi,
> Im trying to calculate z scores in matlab (I don't have the statistics 
> toolbox)
> I have a matrix of 20 x 40 called 'nt'
> I have used the following code
> 
> nt_s = std(nt(:)); 
> nt_mu = mean(mean(nt));
> x=nt-nt_mu;
> nt_z=x./nt_s;

> but this only gives me z scores for each column, when I actually want a 
> zscore for each individual score in the matrix. Any ideas?

Over what population should the means/variance be calculated for the 
standardized variate to be referenced?

If it's the global...oh, I just reread the first line--you did that for 
s via the (:) and by the repeat of mean for mu.  I'd have probably 
written it as

mean(nt(:))

as well, but the result is the same it only avoids the nested call this way.

Well, let's see...

x should be size of nt and thus

nt_z should be as well.

What does

size(nt_z)

return?  Looks to me like it ought to be same as size(nt) unless I 
missed something or you did something other than shown.


> Also I would like an easy way of finding what values in the z score 
> matrix are > +3 and < -3
> 
> I only know how to type Z = nt_Z > 3 and Z = nt_z < -3 separately. These 
> are probably very easy questions, but Im very new to matlab

You can write a compound condition or you could use

Z = nt_z(abs(nt_z>3));

also

doc find

might be of interest as could be the section in the "Getting Started" 
chapter on logical addressing.

--
0
Reply dpb 3/6/2010 3:30:29 PM


dpb wrote:
....

>> Also I would like an easy way of finding what values in the z score 
>> matrix are > +3 and < -3
>>
>> I only know how to type Z = nt_Z > 3 and Z = nt_z < -3 separately. 
>> These are probably very easy questions, but Im very new to matlab
> 
> You can write a compound condition or you could use
> 
> Z = nt_z(abs(nt_z>3));
....

ooops...

 > Z = nt_z(abs(nt_z)>3);

--
0
Reply dpb 3/6/2010 5:58:52 PM

dpb <none@non.net> wrote in message <hmtsha$tui$1@news.eternal-september.org>...
> Tracey wrote:
> > Hi,
> > Im trying to calculate z scores in matlab (I don't have the statistics 
> > toolbox)
> > I have a matrix of 20 x 40 called 'nt'
> > I have used the following code
> > 
> > nt_s = std(nt(:)); 
> > nt_mu = mean(mean(nt));
> > x=nt-nt_mu;
> > nt_z=x./nt_s;
> 
> > but this only gives me z scores for each column, when I actually want a 
> > zscore for each individual score in the matrix. Any ideas?
> 
> Over what population should the means/variance be calculated for the 
> standardized variate to be referenced?
> 
> If it's the global...oh, I just reread the first line--you did that for 
> s via the (:) and by the repeat of mean for mu.  I'd have probably 
> written it as
> 
> mean(nt(:))
> 
> as well, but the result is the same it only avoids the nested call this way.
> 
> Well, let's see...
> 
> x should be size of nt and thus
> 
> nt_z should be as well.
> 
> What does
> 
> size(nt_z)
> 
> return?  Looks to me like it ought to be same as size(nt) unless I 
> missed something or you did something other than shown.

Hi thanks for your reply. Apologies for my delayed response. 

You're right, I had made a mistake in the file that I entered (nt was the mean of another file) - whoops!

thanks for your suggestion for further reading. I'll look that up

Tracey

> 
> 
> > Also I would like an easy way of finding what values in the z score 
> > matrix are > +3 and < -3
> > 
> > I only know how to type Z = nt_Z > 3 and Z = nt_z < -3 separately. These 
> > are probably very easy questions, but Im very new to matlab
> 
> You can write a compound condition or you could use
> 
> Z = nt_z(abs(nt_z>3));
> 
> also
> 
> doc find
> 
> might be of interest as could be the section in the "Getting Started" 
> chapter on logical addressing.
> 
> --
0
Reply Tracey 3/9/2010 8:54:04 AM

3 Replies
387 Views

(page loaded in 0.241 seconds)

Similiar Articles:











7/26/2012 9:56:26 AM


Reply: