From: Blue gRay on
Hi,

I have a matrix X [m x n] and a vector Y [m x 1]

I want to update X following this algorithm

for i=1:m
for j=1:m
if Y(j)<Y(i)
rj = sqrt(sum((X(i,:)-X(j,:)).^2));
B = rj*coeff;
X(i,:) = (1-B)*X(i,:) + B*X(j,:) + ui(iter,:);
end
end
end

A professor said me that there is a possibility to avoid the 2 cycles and
make it just by matrix operations (not exactly that algorithm but similar,
by considering the coefficient B in the (1-B)*X(i,:) like the mean of all
the B for the j that satify Y(j)<Y(i) )

I am trying to figure out how to do that but without success.
Do someone see some tricky solution for it?

Cheers

fff




--- news://freenews.netfront.net/ - complaints: news(a)netfront.net ---
From: Travis Knepp on
"Blue gRay" <ffffffffffffffff(a)hotmail.com> wrote in message <i1q705$2egd$1(a)adenine.netfront.net>...
> Hi,
>
> I have a matrix X [m x n] and a vector Y [m x 1]
>
> I want to update X following this algorithm
>
> for i=1:m
> for j=1:m
> if Y(j)<Y(i)
> rj = sqrt(sum((X(i,:)-X(j,:)).^2));
> B = rj*coeff;
> X(i,:) = (1-B)*X(i,:) + B*X(j,:) + ui(iter,:);
> end
> end
> end
>
> A professor said me that there is a possibility to avoid the 2 cycles and
> make it just by matrix operations (not exactly that algorithm but similar,
> by considering the coefficient B in the (1-B)*X(i,:) like the mean of all
> the B for the j that satify Y(j)<Y(i) )
>
> I am trying to figure out how to do that but without success.
> Do someone see some tricky solution for it?
>
> Cheers
>
> fff
>
>
>
>
> --- news://freenews.netfront.net/ - complaints: news(a)netfront.net ---


What is it, exactly, that you are trying to do? I'm having a hard time following the script you provided to determine what the overall goal is. That may be useful to know.
From: Roger Stafford on
"Blue gRay" <ffffffffffffffff(a)hotmail.com> wrote in message <i1q705$2egd$1(a)adenine.netfront.net>...
> Hi,
>
> I have a matrix X [m x n] and a vector Y [m x 1]
>
> I want to update X following this algorithm
>
> for i=1:m
> for j=1:m
> if Y(j)<Y(i)
> rj = sqrt(sum((X(i,:)-X(j,:)).^2));
> B = rj*coeff;
> X(i,:) = (1-B)*X(i,:) + B*X(j,:) + ui(iter,:);
> end
> end
> end
>
> A professor said me that there is a possibility to avoid the 2 cycles and
> make it just by matrix operations (not exactly that algorithm but similar,
> by considering the coefficient B in the (1-B)*X(i,:) like the mean of all
> the B for the j that satify Y(j)<Y(i) )
>
> I am trying to figure out how to do that but without success.
> Do someone see some tricky solution for it?
>
> Cheers
> fff
- - - - - - - - -
I think as it stands your results in X will in general depend on the order in which the i and j indices are processed. If you wrote "for j=m:-1:1" or "for i=m:-1:1" for example with everything else the same, you should get different results. This is not due solely to the variability of B. It is the order in which the "averaging" actions are performed on X that matters too. In other words there is no "commutative" law in place here - order matters.

It seems a strange way of "updating" X. I suspect that your double loop method is very likely the best way to carry it out if you are convinced this is the exact result you want.

I am speaking of course of this precise algorithm. There may be other more efficient ways of computing if you are satisfied with approximate but different results in X. We have no way of determining this without knowing a lot more about your particular goal in this updating action.

Roger Stafford