Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
roly: double heap moving median
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Keith Goodman  
View profile  
 More options May 2 2011, 3:39 pm
From: Keith Goodman <kwgood...@gmail.com>
Date: Mon, 2 May 2011 12:39:04 -0700
Local: Mon, May 2 2011 3:39 pm
Subject: roly: double heap moving median
I made a first attempt to cython wrap Richard's double heap moving
median C code.

It runs but it gives the wrong output (see below). Any ideas what
could be causing the problem?

I made some changes to Richard's code as you can see here:
https://github.com/kwgoodman/roly/commit/2c5df3a16e5af3df38151a8b4e7c...

I changed the array values from int to double. And instead of
supplying a next_value() function that gives the next value of the
array to the double heap initialization, I passed in a pointer to the
first array element.

Here's the output I get:

>> import roly
>> a = np.arange(10).astype('float64')
>> a

array([ 0.,  1.,  2.,  3.,  4.,  5.,  6.,  7.,  8.,  9.])
>> roly.slow.move_median(a, 3)

array([ nan,  nan,   1.,   2.,   3.,   4.,   5.,   6.,   7.,   8.])
>> roly.linkedlist.move_median(a, 3)

array([ nan,  nan,   1.,   2.,   3.,   4.,   5.,   6.,   7.,   8.])
>> roly.doubleheap.move_median(a, 3)

array([ nan,  nan,   4.,   4.,   4.,   5.,   5.,   6.,   6.,   6.])

Here  are the results for some other window values in case they mean anything:

>> roly.doubleheap.move_median(a, 2)

array([ nan,   4.,   4.,   4.,   4.,   5.,   5.,   6.,   6.,   6.])
>> roly.doubleheap.move_median(a, 3)

array([ nan,  nan,   4.,   4.,   4.,   5.,   5.,   6.,   6.,   6.])
>> roly.doubleheap.move_median(a, 4)

array([ nan,  nan,  nan,   4.,   4.,   5.,   5.,   5.,   6.,   7.])
>> roly.doubleheap.move_median(a, 5)

array([ nan,  nan,  nan,  nan,   4.,   5.,   5.,   6.,   6.,   7.])
>> roly.doubleheap.move_median(a, 6)

array([ nan,  nan,  nan,  nan,  nan,   4.,   4.,   4.,   6.,   7.])
>> roly.doubleheap.move_median(a, 7)

array([ nan,  nan,  nan,  nan,  nan,  nan,   4.,   4.,   4.,   7.])
>> roly.doubleheap.move_median(a, 8)

array([ nan,  nan,  nan,  nan,  nan,  nan,  nan,   4.,   4.,   4.])
>> roly.doubleheap.move_median(a, 9)

array([ nan,  nan,  nan,  nan,  nan,  nan,  nan,  nan,   4.,   4.])
>> roly.doubleheap.move_median(a, 10)

array([ nan,  nan,  nan,  nan,  nan,  nan,  nan,  nan,  nan,   4.])

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Keith Goodman  
View profile  
 More options May 2 2011, 3:52 pm
From: Keith Goodman <kwgood...@gmail.com>
Date: Mon, 2 May 2011 12:52:13 -0700
Local: Mon, May 2 2011 3:52 pm
Subject: Re: roly: double heap moving median

On Mon, May 2, 2011 at 12:39 PM, Keith Goodman <kwgood...@gmail.com> wrote:
> I made a first attempt to cython wrap Richard's double heap moving
> median C code.

> It runs but it gives the wrong output (see below). Any ideas what
> could be causing the problem?

Found it. I told the double heap thingy to use a window equal to the
length of the input array instead of the window that the user inputs.

Works now:

    >> a = np.arange(10).astype('float64')
    >> import roly
    >> roly.doubleheap.move_median(a, 3)
    array([ nan,  nan,   1.,   2.,   3.,   4.,   5.,   6.,   7.,   8.])


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »