Velocity Reviews > Extending Scientific.Statistics.Histogram...

# Extending Scientific.Statistics.Histogram...

bleh
Guest
Posts: n/a

 11-11-2003
....to include a removeData(datatoremove) function, to mirror the
where this has been done already, if you could point me in that
direction I'd be much obliged...

TIA

bleh
Guest
Posts: n/a

 11-12-2003
http://www.velocityreviews.com/forums/(E-Mail Removed) (bleh) wrote in message news:<(E-Mail Removed). com>...
> ...to include a removeData(datatoremove) function, to mirror the
> where this has been done already, if you could point me in that
> direction I'd be much obliged...
>
> TIA

NM -- I figured out the (embarrassingly, ridiculously easy) solution
on my own. Here it is, in case anybody wants it...

import Numeric; N = Numeric
from Scientific.Statistics.Histogram import Histogram

class ExtendedHistogram(Histogram):
def __init__(self, data, nbins, range=None):
Histogram.__init__(self, data, nbins, range)
self._setup(data, nbins, range)

def removeData(self, data):
"""
Remove the values in |data| (a sequence of numbers) from the
originally supplied data. Note that this does not affect the
default range of the histogram, which is fixed when the
histogram is created.
"""
n = (len(data)+999)/1000
for i in range(n):
self._removeData(data[1000*i:1000*(i+1)])

def _removeData(self, data):
data = N.array(data, N.Float)
data = N.repeat(data, N.logical_and(N.less_equal(data, self.max),
N.greater_equal(data, self.min)))
data = N.floor((data - self.min)/self.bin_width).astype(N.Int)
nbins = self.array.shape[0]
data), -1)
histo[-1] = histo[-1] + N.add.reduce(N.equal(nbins, data))
# this next line is the only change... changed the "+" to a "-"
self.array[:, 1] = self.array[:, 1] - histo

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is OffTrackbacks are On Pingbacks are On Refbacks are Off Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post yar Wireless Networking 3 06-15-2005 05:16 PM Stuart Turrell Wireless Networking 6 11-30-2004 10:18 PM Dak991 Cisco 1 11-23-2004 06:48 PM Stibloc Cisco 3 02-29-2004 02:34 AM Rick G Cisco 2 07-11-2003 09:22 PM