COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### z scores without the stats toolbox

• Email
• 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

```
 0

See related articles to this posting

```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"

--
```
 0

```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

```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.

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

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"
>
> --
```
 0