Download software Tutorial videos
Subscription & data-feed pricing Class schedule


New account application Trading resources
Margin rates Stock & option commissions

Attention: Discussion forums are read-only for extended maintenance until further notice.
Welcome Guest, please sign in to participate in a discussion. Search | Active Topics |

PCF for Order Statistics Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
bustermu
Posted : Tuesday, June 28, 2005 11:06:33 AM
Registered User
Joined: 1/1/2005
Posts: 2,645
Suppose we have a sequence of N numbers x(1),x(2),...,x(N ). If we rearrange them in ascending order, with the notation of Order Statistics, they become x[1],x[2],...,x[N] with x[1] being the least and x[N] being the greatest. We wish to write a PCF which returns the value x[j].

Define A(n ) and B(n ), n = 1,2,...,N, to be PCF's of the form:

A(n ) = (-1)*((x(n )>x(1))+(x(n )>x(2))+...+(x(n )>x(N )))

and

B(n ) = (-1)*((x(n )<x(1))+(x(n )<x(2))+...+(x(n )<x(N )))

We now have x(n ) = x[j] if and only if:

(A(n )<=j-1)*(B(n )<=N-j) = 1

Continuing, we have x[j] given by:

((A(1)<=j-1)*(B(1)<=N-j)*x(1)+(A(2)<=j-1)*(B(2)<=N-j)*x(2)
+...+(A(N )<=j-1)*(B(N )<=N-j)*x(N ))
/((A(1)<=j-1)*(B(1)<=N-j)+(A(2)<=j-1)*(B(2)<=N-j)
+...+(A(N )<=j-1)*(B(N )<=N-j))

The numerator is the sum of the x(n )'s which are equal to x[j] and the denominator divides by the number of x(n )'s which are equal to x[j].

For example, if x(1),x(2). x(3), are C0,C1,C2, then x[2] is the median. A PCF for the median filter of period 3 on closing prices is:

(((-1)*((C0>C1)+(C0>C2))<=1)*((-1)*((C0<C1)+(C0<C2))<=1)*C0
+((-1)*((C1>C0)+(C1>C2))<=1)*((-1)*((C1<C0)+(C1<C2))<=1)*C1
+((-1)*((C2>C0)+(C2>C1))<=1)*((-1)*((C2<C0)+(C2<C1))<=1)*C2)
/(((-1)*((C0>C1)+(C0>C2))<=1)*((-1)*((C0<C1)+(C0<C2))<=1)
+((-1)*((C1>C0)+(C1>C2))<=1)*((-1)*((C1<C0)+(C1<C2))<=1)
+((-1)*((C2>C0)+(C2>C1))<=1)*((-1)*((C2<C0)+(C2<C1))<=1))

As another example, let x(1),x(2),x(3),x(4), be C0,C1,C2,C3. Then x{3} is the second largest of these values. A PCF for x[3] is:

(((-1)*((C0>C1)+(C0>C2)+(C0>C3))<=2)
*((-1)*((C0<C1)+(C0<C2)+(C0<C3))<=1)*C0
+((-1)*((C1>C)+(C1>C2)+(C1>C3))<=2)
*((-1)*((C1<C)+(C1<C2)+(C1<C3))<=1)*C1
+((-1)*((C2>C)+(C2>C1)+(C2>C3))<=2)
*((-1)*((C2<C)+(C2<C1)+(C2<C3))<=1)*C2
+((-1)*((C3>C)+(C3>C2)+(C3>C1))<=2)
*((-1)*((C3<C)+(C3<C2)+(C3<C1))<=1)*C3)
/(((-1)*((C0>C1)+(C0>C2)+(C0>C3))<=2)
*((-1)*((C0<C1)+(C0<C2)+(C0<C3))<=1)
+((-1)*((C1>C)+(C1>C2)+(C1>C3))<=2)
*((-1)*((C1<C)+(C1<C2)+(C1<C3))<=1)
+((-1)*((C2>C)+(C2>C1)+(C2>C3))<=2)
*((-1)*((C2<C)+(C2<C1)+(C2<C3))<=1)
+((-1)*((C3>C)+(C3>C2)+(C3>C1))<=2)
*((-1)*((C3<C)+(C3<C2)+(C3<C1))<=1)))

Of course, the order statistics can also be written using max(a,b) and min(a,b).

Any comments will be appreciated.

Thanks,
Jim Murphy
Tanstaafl
Posted : Wednesday, June 29, 2005 9:56:31 AM
Registered User
Joined: 10/7/2004
Posts: 799
Location: Duluth, GA
I think that you can remove all instances of "(-1)" from your formula, as long as the number of <=N terms is even.

That's not much of a contribution ... your work is excellent, as usual.

Jim Dean

bustermu
Posted : Wednesday, June 29, 2005 1:43:53 PM
Registered User
Joined: 1/1/2005
Posts: 2,645
Jim D.,

The (-1)'s come from the definitions of the A(n )'s and B(n )'s. They can be disposed of by writing:

(A(n )<=j-1)*(B(n )<=N-j)

as:

((-1)*A(n )>=1-j)*((-1)*B(n )>=j-N)

But, I don't think this is what you had in mind. I believe you misread something.

Thanks,
Jim Murphy
Tanstaafl
Posted : Tuesday, July 5, 2005 10:28:10 AM
Registered User
Joined: 10/7/2004
Posts: 799
Location: Duluth, GA
Hi, JimM:

Isn't it true that:
((-1)*((C0>C1)+(C0>C2)+(C0>C3))<=2)
*((-1)*((C0<C1)+(C0<C2)+(C0<C3))<=1)*C0

Is equivalent to:
((C0>C1)+(C0>C2)+(C0>C3)) > -2)
*((C0<C1)+(C0<C2)+(C0<C3) > -1)*C0

???

That is the transform I was referring to. I did fail to mention that the <= +N must change to > -N.

Jim Dean

bustermu
Posted : Tuesday, July 5, 2005 11:14:33 AM
Registered User
Joined: 1/1/2005
Posts: 2,645
Jim D.,

No. But you are very close. The equivalent PCF is:

((C0>C1)+(C0>C2)+(C0>C3))>=-2)
*((C0<C1)+(C0<C2)+(C0<C3)>=-1)*C0

The equality stays.

This is exactly the transformation demonstrated in the response to your first post. It has nothing to do with any number of terms being even. That is what threw me off in your first post.

Thanks,
Jim Murphy
Tanstaafl
Posted : Tuesday, July 5, 2005 12:39:12 PM
Registered User
Joined: 10/7/2004
Posts: 799
Location: Duluth, GA
Gotcha ... the equals sign would not be required if the thresholds in the example were -3 and -2. Just trying to clean it up a bit ... I have this wierd desire to eliminate -1 multipliers whenever I can ... no big deal.

Thanks for the clarification.

Jim Dean

Users browsing this topic
Guest-1

Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.