[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Zero or not?
From: |
kensmith |
Subject: |
Re: Zero or not? |
Date: |
Tue, 24 Jul 2007 08:03:49 -0700 |
User-agent: |
KMail/1.9.1 |
On Tuesday 24 July 2007 07:47, Przemek Klosowski wrote:
> I'm new to "octave". I'm translating from a method I use in
> "pascal"
>
> Avg = sum(abs(X))/(size(X)(2)); # Figure a dividing line
>
> Or you could just say Avg=mean(X);
>
> Gate = Avg < abs(X); # Classify X
>
> Total = sum(X .* Gate) + sum(X .* !Gate);
>
> Or, simpler, avg=mean(x); sum(x(x>=avg)) + sum(x(x<avg))
Make that:
avg = mean(abs(x))
You may be working with different signed values.
>
> I must say that this method is surprisingly good: twice as fast
> as the full sort, while getting most of the accuracy:
>
> x=exp(100*rand(1,1000000));
>
> tic; avg=mean(x); sum(x(x>=avg)) + sum(x(x<avg))-sum(x), toc
> ans = 7.3219e+34
> Elapsed time is 0.308838 seconds.
> tic; sum(sort(x))-sum(x), toc
> ans = 7.0664e+34
> Elapsed time is 0.689682 seconds.
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://www.cae.wisc.edu/mailman/listinfo/help-octave
--
address@hidden
- Re: Zero or not?, (continued)
- Re: Zero or not?, Ben Abbott, 2007/07/21
- Re: Zero or not?, Matthias Brennwald, 2007/07/22
- Re: Zero or not?, James Sherman Jr., 2007/07/22
- Re: Zero or not?, Matthias Brennwald, 2007/07/23
- Re: Zero or not?, Francesco Potorti`, 2007/07/23
- Re: Zero or not?, James Sherman Jr., 2007/07/23
- Re: Zero or not?, Miroslaw Kwasniak, 2007/07/23
- Re: Zero or not?, Francesco Potorti`, 2007/07/24
- Re: Zero or not?, kensmith, 2007/07/24
- Re: Zero or not?, Przemek Klosowski, 2007/07/24
- Re: Zero or not?,
kensmith <=
- Re: Zero or not?, Francesco Potorti`, 2007/07/22
- Re: Zero or not?, Miroslaw Kwasniak, 2007/07/23
- Re: Zero or not?, Francesco Potorti`, 2007/07/23
- Re: Zero or not?, kensmith, 2007/07/23
- Re: Zero or not?, Przemek Klosowski, 2007/07/23
- Re: Zero or not?, Robert A. Macy, 2007/07/21
Re: Zero or not?, Bob Weigel, 2007/07/21