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

### standard deviation

• Email
• Follow

```Hello,

I need to get the standar deviation from a vector, but the promem is that inside that vector I have some zero value that can not be included in the calculation.

I mean lets say I have the vector A=[5, 6, 8, 0, 4,8, 0, 8]
I need the standard deviation without considering zero values.

Thank you very much for your help.
Jose
```
 0
Reply Jose 12/28/2009 8:06:04 PM

See related articles to this posting

```"Jose " <mylordjose@hotmail.com> wrote in message <hhb33c\$d0a\$1@fred.mathworks.com>...
> Hello,
>
> I need to get the standar deviation from a vector, but the promem is that inside that vector I have some zero value that can not be included in the calculation.
>
> I mean lets say I have the vector A=[5, 6, 8, 0, 4,8, 0, 8]
> I need the standard deviation without considering zero values.
>
> Thank you very much for your help.
> Jose

Asorted=sort(A);
zeroloc=find(A==0);
ANoZeros=Asorted(max(zeroloc)+1:length(Asorted));
StandardDeviation=std(ANoZeros);
```
 0
Reply Vince 12/28/2009 8:17:05 PM

```"Vince Petaccio" <vince@moberg.com> wrote in message <hhb3o1\$nb9\$1@fred.mathworks.com>...
> "Jose " <mylordjose@hotmail.com> wrote in message <hhb33c\$d0a\$1@fred.mathworks.com>...
> > Hello,
> >
> > I need to get the standar deviation from a vector, but the promem is that inside that vector I have some zero value that can not be included in the calculation.
> >
> > I mean lets say I have the vector A=[5, 6, 8, 0, 4,8, 0, 8]
> > I need the standard deviation without considering zero values.
> >
> > Thank you very much for your help.
> > Jose
>
> Asorted=sort(A);
> zeroloc=find(A==0);
> ANoZeros=Asorted(max(zeroloc)+1:length(Asorted));
> StandardDeviation=std(ANoZeros);

or
std(A(A~=0))
```
 0
Reply Dave 12/28/2009 8:30:06 PM

```"Jose " <mylordjose@hotmail.com> wrote in message <hhb33c\$d0a\$1@fred.mathworks.com>...
> Hello,
>
> I need to get the standar deviation from a vector, but the promem is that inside that vector I have some zero value that can not be included in the calculation.
>
> I mean lets say I have the vector A=[5, 6, 8, 0, 4,8, 0, 8]
> I need the standard deviation without considering zero values.
>
> Thank you very much for your help.
> Jose

% No need to do any sorting:

A=[5, 6, 8, 0, 4,8, 0, 8];
s=std(A(A~=0));
```
 0
Reply Andy 12/28/2009 8:37:04 PM

```"Jose " <mylordjose@hotmail.com> wrote in message <hhb33c\$d0a\$1@fred.mathworks.com>...
> Hello,
>
> I need to get the standar deviation from a vector, but the promem is that inside that vector I have some zero value that can not be included in the calculation.
>
> I mean lets say I have the vector A=[5, 6, 8, 0, 4,8, 0, 8]
> I need the standard deviation without considering zero values.
>
> Thank you very much for your help.
> Jose

^ What they said. :oD
```
 0
Reply Vince 12/28/2009 8:43:04 PM

```Thanks a lot!
```
 0
Reply Jose 12/28/2009 8:48:04 PM

```Thanks a lot!
```
 0
Reply Jose 12/28/2009 8:48:04 PM

```Thanks a lot!
```
 0
Reply Jose 12/28/2009 8:49:04 PM

```"Jose " <mylordjose@hotmail.com> wrote in message <hhb33c\$d0a\$1@fred.mathworks.com>...
> Hello,
>
> I need to get the standar deviation from a vector, but the promem is that inside that vector I have some zero value that can not be included in the calculation.
>
> I mean lets say I have the vector A=[5, 6, 8, 0, 4,8, 0, 8]
> I need the standard deviation without considering zero values.
>
> Thank you very much for your help.
> Jose
Maybe logical addressing might be an alternative.
grunk = std(A(A~=0));

m-lint always seem to tell me logical addressing is faster than find.
I'd have to say though, that if you can, change your flag value: using say, nan rather than 0 would be clearer as 0 is a valid numerical value.
grunk = std(A(~isnan(A));
```
 0
Reply Neil 12/28/2009 9:10:19 PM

8 Replies
227 Views

Similar Articles

12/10/2013 12:13:39 PM
[PageSpeed]

Similar Artilces:

Options for CDwriter on G4?
I'm thinking about putting a CD-writer into the empty bay in my 350mhz G4. Do I have any options or is there just one from Apple that will work? thanks, Tim Tim Hohs <record@ctcweb.net> wrote: > I'm thinking about putting a CD-writer into the empty bay in my 350mhz > G4. Do I have any options or is there just one from Apple that will work? Oh, do you ever have options! These are compatible with both Disc Burner and iTunes in OS 9: http://docs.info.apple.com/article.html?artnum=61639 And these are compatible in OS X: http://www.apple.com/macosx/upgrade/storage.html

Looking for a standard pattern
I have a simple requirement. I have a input flat file which contains some record and I want to import those records into a database (using some class and mapping the input fields to the database). Is there any standard design pattern I can apply to accomplish the task? As this is a very common problem/requirement, any help is appreciated. On Wed, 18 Feb 2004 04:39:43 -0800, Saikat Bhattacharjee wrote: > I have a simple requirement. I have a input flat file which contains > some record and I want to import those records into a database (using > some class and mapping the input fields to the database). Is there any > standard design pattern I can apply to accomplish the task? As this is > a very common problem/requirement, any help is appreciated. Regular expressions may do most of the job for you. Let say you have an input file, where a line looks like this: field1 field2 field3 Separated by spaces Then we can make a regexp /^(\S+)\s(\S+)\s(\S+)\$/ and match that against the input. Is this what you want? -- Simon Strandgaard Responding to Bhattacharjee... > I have a simple requirement. I have a input flat file which contains > some record and I want

Standard(s) ... and all that Jazz
I may or may not reply to Jimmy's long post (which distorts some truths - but certainly is a "reasonable" way to view what has happened). A couple of "facts" 1) J4/WG4 moved VERY quickly and *did* get the first TR (Technical Report) approved to "enhance" the 2002 Standard 2) J4/WG4 is fairly far along in getting two more TR's finished and approved (these will include the "widely requested" XML and "collection classes" enhancements) 3) J4/WG4 is working as hard as they can to MAKE the year 2008 for the NEXT standard .... on the other hand A) J4 is continuing to lose members (and/or having less attendees) B) As Jimmy indicated, I have seen minimal progress toward ANY "fully conforming" 2002 Standard. (From "hints" - I think that Siemens/Fujitsu is closer to Micro Focus who INITIALLY committed publicly to doing so) C) Until there is an "initial" draft of the 2008 Standard out for "public review" (IMHO) all dates are totally a "guess". Without a 2002 conforming compiler, I don't know what difference any of this means. -- Bill Klein wmklein <at>

Standard Solaris Builds #2
Hi Guys, Has anyone used www.standardbuild.com - the concept seems pretty sound just want a feel for their service standards.

Bad initialization example in standard?
In 12.6.1 of n2521, it says: "When an aggregate (whether class or array) contains members of class type and is initialized by a brace- enclosed initializer list, each such member is copy-initialized by the corresponding assignment-expression." Then the example is given: complex v[6] = { 1, complex(1,2), complex(), 2 }; where 'complex' is a small class defined in the 12.6 for exemplary purposes. According to the above paragraph, v[1] should be copy-constructed from the temporary complex(1,2). However, the explanation of the example code says: "complex::co

PIX and NDPS printers
I have a 506e that seems to be working fine. I am going to move my NDPS printers behind it but can't seem to get them to work. The printer has a static internal IP that is statically mapped; if I try to print nothing happens. Is there any way to make this combo work? Did you configure an access-list on the outside interface to permit the NDPS traffic ? PIX do not allow outside traffic to establish a session to the inside interface without being permitted by an access list mh wrote: > Did you configure an access-list on the outside interface to permit > the NDPS traffic ? > >

struts standard unit test cases
I am just wondering if there are some existing standard test cases that can be used for the struts testing. For the users, all he needs to do is to build the test cases, deploy it and run it ? thanks, cji Charlie wrote: > I am just wondering if there are some existing standard test cases > that can be used for the struts testing. For the users, all he needs > to do is to build the test cases, deploy it and run it ? > > You might want to try this: http://strutstestcase.sourceforge.net/

check conformity with FTP's standard