help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Vector approach to row margin frequencies


From: Judd Storrs
Subject: Re: Vector approach to row margin frequencies
Date: Wed, 24 Jun 2009 13:17:41 -0400

On Wed, Jun 24, 2009 at 10:56 AM, Jaroslav Hajek <address@hidden> wrote:
On Wed, Jun 24, 2009 at 4:48 PM, ws<address@hidden> wrote:
>> In 3.2.0, the fastest way is also the most obvious (from math point of view):
>>
>> F = X / diag (S)
>>
>> In 3.0.x, take any of the bsxfun or repmat workarounds (or just use
>> the above and upgrade to 3.2 soon)
>
> Well ....
>
> octave:7> version
> ans = 3.2.0
> octave:8> X/diag(S)
> error: operator /: nonconformant arguments (op1 is 16x3, op2 is 16x16)
>
> I will play with the bsxfun thing, though, just to understand it...
>
> Thanks!

Oh yes, sorry, I confused rows and columns. diag(S) \ X

Nah, you just didn't specifiy what S was ;) Depending on whether S is sum(X,1) or sum(X,2) you need one of the following:

X / diag(sum(S,1))
diag(sum(S,2)) \ X

The diag() stuff is really cool. Now I'll have to look into whether reshape+diag+reshape is faster than bsxfun for 3D arrays. Thanks Jaroslav!

--judd
 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]