Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Identifying Upward and Downward Trends
Replies: 5   Last Post: Apr 5, 2013 12:50 AM

 Messages: [ Previous | Next ]
 Konstantine Posts: 34 Registered: 5/3/11
Re: Identifying Upward and Downward Trends
Posted: Apr 3, 2013 1:05 PM

I think I have a direction:

If I use the function peakdet (http://www.billauer.co.il/peakdet.html) I can find the maximums and minimums of the plot. I can then find the first minimum and the maximum value that follows it. After I make sure that the length of the two vectors match, I find the difference between the subsequent maximums and minimums. Where there is an upward trend, the variability of the differences is much higher than when there is a downward trend. Basically, when there is a upward trend there are a lot more data points between maximums and the minimums behind them. Whereas on downward trending data, there are typically very few (mostly no) data points between maximums and the minimums preceding them.

You can use the data I supplied earlier to test this out, swapping 'upward' and 'downward' as needed.

[maxtab, mintab] = peakdet(upward,10);
%plot(upward;hold on; plot(mintab(:,1), mintab(:,2), 'g*'); plot(maxtab(:,1), maxtab(:,2), 'r*');

compMaxes = find(maxtab(:,1)>mintab(1,1));
numMax = numel(compMaxes);
numMin = numel(mintab(:,1));
if numMax > numMin
var(maxtab(compMaxes(1:numMin,1)) - mintab(:,1))
elseif numMax < numMin
var(maxtab(compMaxes,1) - mintab(1:numMax,1))
else
var(maxtab(compMaxes,1) - mintab(:,1))
end

I'm sure this can be cleaned up a lot, but it works for now. Any direction would be very appreciated.

Thanks,
K

Date Subject Author
4/2/13 Konstantine
4/2/13 Derek Goring
4/3/13 Konstantine
4/3/13 Konstantine
4/4/13 Konstantine
4/5/13 Derek Goring