🎉Community Raffle - Win $25

An exclusive raffle opportunity for active members like you! Complete your profile, answer questions and get your first accepted badge to enter the raffle.
Join and Win

[Solved] - Using the prior value of an attribute to calculated the current value

User: "CharlieG"
New Altair Community Member
Updated by Jocelyn
I'm trying to label examples as to whether they're part of a trend that's gernerlly upward or generally downward.  I've got the first part working.  I'm calculating the difference between successive examples using the Differentiate operator and then using Generate Attribute to assign a label based on the sign of the difference.  Here's an example:

MovingAvg   DeltaMovingAvg     Trend
0.629           ?                       Up (arbitary choice)
0.600           -0.029                 Down
0.571           -0.029                 Down
0.557           -0.014                 Down
0.586           0.029                   Up
0.583           -0.003                 Down
0.583           0                       Up
0.597           0.014                   Up

So far so good.  But I really don't want the little value of -0.003 to get in the way of a generally upward trend.  So I'd like to add a rule that says - if the value of the difference is less than a threshold (say 0.02) then don't change the label on the trend from what it was in the previous example.  After applying this rule I'd get:

MovingAvg   DeltaMovingAvg     Trend
0.629           ?                       Up (arbitary choice)
0.600           -0.029                 Down
0.571           -0.029                 Down
0.557           -0.014                 Down
0.586           0.029                   Up
0.583           -0.003                 Up
0.583           0                       Up
0.597           0.014                   Up

I suspect I need a Loop Example to do this but I can't find a good example of how to use Loop Example.  Can anyone point me to a simple tutorial on Loop Example?  Or is there an easier way to do this?

Find more posts tagged with