in reply to Re^2: How to Determine Stable Y-Values... or Detect an Edge..?
in thread How to Determine Stable Y-Values... or Detect an Edge..?
Can you give me a quick explanation of what the middle line is doing?
$#moving is the highest numbered element in the array--ie. one less than the total number of elements, as indexes start at zero.
The statement next if $#moving < ($MOVES / 2);, says: skip the moving average calculations until we have at least half as many values in the bank as the period of the moving average. Ie. If we are calculating the moving average over 50 values, don't start until we have at least 25 accumulated.
The effect of the line, is to correct for the lag that is normally associated with moving averages. Effectively adding a -X(P/2) correction to the moving averages trace, by discarding the first P/2 moving average values, which would be calculated from less than P/2 inputs and so be dubious anyway.
I don't KNOW those values. Is there a means to simply determine those values from the data...
First. It was not at all clear in your OP that you did not know these transitions. Quite the reverse actually. The entire emphasis of your post was how to determine the points of transition between (predetermined) "steady state" levels. Not determining those levels. Sorry if I misread your intent?
To answer the question, can they be determined from the data, I'll come back to the question from my earlier post. Are you doing this statically--ie. with all the data known up front--or dynamically--as the data is accumulated?
And add a second question: How will you access whether the levels you choose--whether by inspection or calculation--are the correct ones?
My point being that it is pretty clear if you inspect the frequency analysis of the values in your sample data:
C:\test>junk9 44 : 481 (43.18%) 90 : 176 (15.80%) 120 : 127 (11.40%) 100 : 56 (5.03%) 102 : 24 (2.15%) 101 : 21 (1.89%) 104 : 19 (1.71%) 99 : 17 (1.53%) 115 : 14 (1.26%) 98 : 13 (1.17%) 92 : 12 (1.08%) 107 : 12 (1.08%) 106 : 12 (1.08%) 97 : 12 (1.08%) 108 : 11 (0.99%) 95 : 10 (0.90%) 112 : 10 (0.90%) 105 : 10 (0.90%) 117 : 9 (0.81%) 118 : 8 (0.72%) 110 : 8 (0.72%) 109 : 8 (0.72%) 96 : 7 (0.63%) 111 : 7 (0.63%) 114 : 6 (0.54%) 113 : 5 (0.45%) 93 : 5 (0.45%) 103 : 4 (0.36%) 119 : 3 (0.27%) 91 : 3 (0.27%) 94 : 3 (0.27%) 116 : 1 (0.09%)
that if you want(need, desire, see) 3 transition levels, then 44, 90 & 120 are the ones to pick. If you want or need 4 values it is also fairly clear. But what about 5? Do you pick 101 or 102?
If you calculate these values somehow--say, using wavelets, or short-time Fourier transforms--then you are quite likely to get numbers resembling: 44.8972321, 91.00002, 102.87563, 119.0300657, or similar. That is, the calculations are likely to produce output values that don't actually appear in your input data. And if you attempt to round or truncate them to values that do appear, then you will likely end up with transition level values that are wholly unrepresentative of the inputs in terms of frequency--because that is the nature of the math.
So the question becomes: What are you going to do with these values? What use are you intending to make of them? How critical is the outcome? Will lives depend upon it? Or just the position of a line on a presentation graph? Without some clues as to the purpose, it is difficult to make suggestions!
Several possibilities come to mind that might be appropriate to some purposes.
In which case, sort the inputs by frequency and pick the top 3(N).
For the sample data, if you decided 10%, then you get the 3 transitions at 44, 90 & 120. If you decided 5%, then you gain an extra level at 100.
You might favour a selection policy based around the mean deviation.
So any value that falls with 1 standard deviation of the mean constitutes a level.
With a little more thought, I could come up with half a dozen other possibilities, but which if any is appropriate to your purpose, depends very much upon that purpose.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: How to Determine Stable Y-Values... or Detect an Edge..?
by ozboomer (Friar) on Aug 24, 2009 at 00:24 UTC |