Re: Simplify formula for iterative programming
- From: cri@xxxxxxxx (Richard Harter)
- Date: Fri, 03 Jun 2005 14:49:30 GMT
On 3 Jun 2005 03:32:16 -0700, stefaan.lhermitte@xxxxxxxxxxxxxxxxxx
wrote:
Meta comment: Your question is virtually unreadable because the
character set is getting munged. I'm not going to attempt to answer
your question when it is in this format. That said, see comments at
bottom.
>Dear,
>
>I am looking for the simplification of a formula to improve the
>calculation speed of my program. Therefore I want to simplify the
>following formula:
>
>H =3D Si (Sj ( sqrt [ (Ai - Aj)=B2 + (Bi - Bj)=B2 ] ) )
>
>where:
>A, B =3D two vectors (with numerical data) of length n
>sqrt =3D square root
>Si =3D summation over i (=3D 0 to n)
>Sj =3D summation over j (=3D 0 to n)
>Ai =3D element of A with index i
>Aj =3D element of A with index j
>Bi =3D element of B with index i
>Bj =3D element of B with index j
>
>n is not fixed, but it changes with every run for my program. Therefore
>for I am looking for a simplication of H in order to calculate it when
>my A and B get extendend by 1 element (n =3D n + 1).
>
>I know a computional simplified formula exists for the standard
>deviation (sd) that is much easier in iterative programming. Therefore
>I wondered I anybody knew about analog simplifications to simplify H:
>
>sd =3D sqrt [ ( Si (Xi - mean(X) )=B2 ) /n ] -> simplified computation
>-> sqrt [ (n * Si( X=B2 ) - ( Si( X ) )=B2 )/ n=B2 ]
>
>This simplied formula is much easier in iterative programming, since I
>don't have to keep every element of X.
>E=2Eg.: I have a vector X[1:10] and I already have caculated Si(
>X[1:10]=B2 ) (I will call this A) and Si( X ) (I will call this B).
>When X gets extendend by 1 element (eg. X[11]) it easy fairly simple to
>calculate sd(X[1:11]) without having to reuse the elements of X[1:10].
>I just have to calculate:
>
>sd =3D sqrt [ (n * (A + X[11]=B2) - (A + X[11]=B2)=B2 ) / n=B2 ]
>
>This is fairly easy in an iterative process, since before we continue
>with the next step we set:
>A =3D (A + X[11]=B2)
>B =3D (B + X[11])
>
>Can anybody help me to do something comparable for H? Any other help to
>calculate H easily in an iterative process is also welcome!
>
>Kind regards,
>Stef
>\
If, as I guessing, your H is the sum over i,j of point distances from
each other (that's what your formula looks like) then there is no
really nice extension formula. In the standard deviation formula you
are taking the square root of a sum; in your case you are taking the
sum of square roots. That said you can use the general extension
formula, e.g.,
H(n+1) = H(n) + sum_over_i(E(i,n+1) + E(n+1,i)) + E(n+1,n+1)
where E(1,j) is term i,j in the summation. This isn't any faster
overall, but it does let you use previous results.
Richard Harter, cri@xxxxxxxx
http://home.tiac.net/~cri, http://www.varinoma.com
Save the Earth now!!
It's the only planet with chocolate.
.
- References:
- Simplify formula for iterative programming
- From: stefaan . lhermitte
- Simplify formula for iterative programming
- Prev by Date: Re: Simplify formula for iterative programming
- Next by Date: Re: Simplify formula for iterative programming
- Previous by thread: Re: Simplify formula for iterative programming
- Next by thread: Re: Simplify formula for iterative programming
- Index(es):
Relevant Pages
|