Re: Programmatically finding "significant" data points
- From: "Fredrik Lundh" <fredrik@xxxxxxxxxxxxxx>
- Date: Tue, 14 Nov 2006 15:14:50 +0100
"erikcw" wrote:
I have a collection of ordered numerical data in a list. The numbers
when plotted on a line chart make a low-high-low-high-high-low (random)
pattern. I need an algorithm to extract the "significant" high and low
points from this data.
Here is some sample data:
data = [0.10, 0.50, 0.60, 0.40, 0.39, 0.50, 1.00, 0.80, 0.60, 1.20,
1.10, 1.30, 1.40, 1.50, 1.05, 1.20, 0.90, 0.70, 0.80, 0.40, 0.45, 0.35,
0.10]
silly solution:
for i in range(1, len(data)-1):
if data[i-1] < data[i] > data[i+1] or data[i-1] > data[i] < data[i+1]:
print i
(the above doesn't handle the "edges", but that's easy to fix)
</F>
.
- References:
- Programmatically finding "significant" data points
- From: erikcw
- Programmatically finding "significant" data points
- Prev by Date: Re: Programmatically finding "significant" data points
- Next by Date: modules and generated code
- Previous by thread: Re: Programmatically finding "significant" data points
- Next by thread: Re: Programmatically finding "significant" data points
- Index(es):
Relevant Pages
|