Skip to main content
Question

Best way to find a change of sign

  • July 13, 2017
  • 8 replies
  • 190 views

jdh
Contributor
Forum|alt.badge.img+40

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.

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

8 replies

erik_jan
Contributor
Forum|alt.badge.img+26
  • 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+40
  • Author
  • 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.

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+26
  • Contributor
  • July 13, 2017
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+26
  • Contributor
  • July 13, 2017
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+46
  • 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
Celebrity
  • 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
Celebrity
  • 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.

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+40
  • Author
  • Contributor
  • July 14, 2017
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.