Skip to main content
Question

Best way to find a change of sign


jdh
Contributor
Forum|alt.badge.img+28
  • Contributor

I have some ordered features that contain a value, and I need to identify the inflection points, ie the feature where the sign (+/-) of the attribute value changes compared to the previous feature

 

 

ex. features have values [2,3,1,-2,-1,1,3] the inflection points would be features 3 and 5

For added entertainment there is another attribute containing a common ID, and I need to break on that value.

8 replies

erik_jan
Contributor
Forum|alt.badge.img+17
  • Contributor
  • July 13, 2017

I will give it a try:

Create a new attribute ABS with conditional value (if value = @abs(value) then Y else N).

Then create the test between the current and the previous feature (ABS = ABS(feature(-1))

That should list the changes in the Failed port of the Tester.


jdh
Contributor
Forum|alt.badge.img+28
  • Author
  • Contributor
  • July 13, 2017
erik_jan wrote:

I will give it a try:

Create a new attribute ABS with conditional value (if value = @abs(value) then Y else N).

Then create the test between the current and the previous feature (ABS = ABS(feature(-1))

That should list the changes in the Failed port of the Tester.

I tried using an attributeCreator with the expression ((@Value(X)>=0)==(@Value(feature[-1].X)>=0)),

 

 

But I'm not sure how to prevent the first feature from one group checking against the last feature of the previous group.

erik_jan
Contributor
Forum|alt.badge.img+17
  • Contributor
  • July 13, 2017
jdh wrote:
I tried using an attributeCreator with the expression ((@Value(X)>=0)==(@Value(feature[-1].X)>=0)),

 

 

But I'm not sure how to prevent the first feature from one group checking against the last feature of the previous group.
In my example I would add to the Tester:

 

And group = group(feauture(-1))

 

 


erik_jan
Contributor
Forum|alt.badge.img+17
  • Contributor
  • July 13, 2017
jdh wrote:
I tried using an attributeCreator with the expression ((@Value(X)>=0)==(@Value(feature[-1].X)>=0)),

 

 

But I'm not sure how to prevent the first feature from one group checking against the last feature of the previous group.
Let me change that to:

 

Or group != group(feature(-1))

 

That will pass the first in each group.

 

 


ebygomm
Influencer
Forum|alt.badge.img+33
  • Influencer
  • July 13, 2017

Might need tweaking to handle first and last features but you probably want a conditional statement with a composite test

e.g.


takashi
Influencer
  • July 14, 2017

Hi @jdh, if I understood the requirement correctly, this should work as expected.

[Addition] Assume that 0 won't occur in the values sequence.


takashi
Influencer
  • July 14, 2017
takashi wrote:

Hi @jdh, if I understood the requirement correctly, this should work as expected.

[Addition] Assume that 0 won't occur in the values sequence.

0684Q00000ArLJhQAN.png

If 0 could occur in the sequence and 0 can be considered as a positive value, this Test Condition might work a treat. 

 

@Evaluate((@Value(feature[-1].value)==0 ? 1 : @Value(feature[-1].value)) * (@Value(value)==0 ? 1 : @Value(value))) < 0
If you consider 0 as a negative value, replace "1" in the expression with a negative value e.g. "-1".

jdh
Contributor
Forum|alt.badge.img+28
  • Author
  • Contributor
  • July 14, 2017
takashi wrote:
If 0 could occur in the sequence and 0 can be considered as a positive value, this Test Condition might work a treat. 

 

@Evaluate((@Value(feature[-1].value)==0 ? 1 : @Value(feature[-1].value)) * (@Value(value)==0 ? 1 : @Value(value))) < 0
If you consider 0 as a negative value, replace "1" in the expression with a negative value e.g. "-1".
I believe we have to allow for 0 in the sequence, because the first feature has no prior feature and would use the default value of 0.   In that case it would ideally be neutral, so I think your first equation works as is.

 

 


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings