Jump to content

Cumulative Sum of a signal


Rezwan

Recommended Posts

Hello, 

I am trying to create a cumulative sum of Sig 1 using runningSum() within the condition "Cond". The following code was used. 

$Sig1.runningSum($Cond.merge(10s,true).removeLongerThan(3d))

merge() was used to get rid of all the capsules in $Cond and not it to reset before end of the condition.  

The reported number in the Sig 2 is not matching up the number of Sig1 if it is added manually such as data started at 3731, the next data point is 644 in Sig1. So. the second step in Sig 2 should be 4375, but runningSum() is calculating it as 8107.  Any suggestion what can be done to correct it. 

image.thumb.png.0b560ac2637ca9f0e73926798271c3d1.png

Link to comment
Share on other sites

  • Seeq Team

Hi Rezwan,

When you have a signal that is step interpolated, it may count twice (when the first sample is dropped and when the last sample is dropped). I'd suggest doing $signal.todiscrete() prior to the summation and verify that there is only one sample point per value shown on your screen. If so, then complete the running sum equation.

  • Thanks 1
Link to comment
Share on other sites

Thanks Joe for the quick response. It worked, but I needed to convert the signal back to step and I did it as:

$series.aggregate(sum(), $capsules.setMaximumDuration(40h), durationKey())

Any simpler ways to convert this to step again.  

For Sig1, you can see that there is no line in the first drop or I would say missing data point. tried to use setmaxinterpolate(), but it is not filling the gaps. Any suggestions on this would be much appreciated. 

Thanks. 

 

Edited by Rezwan
clarification of statements.
Link to comment
Share on other sites

  • Seeq Team

There is a .tostep(<max interpolation>) that is the easiest method. However, if it does not interpolate even though the data is within the max interpolation, that means that you likely have invalid values somewhere in the signal. You can remove those with .validvalues()

Edited by Joe Reckamp
Link to comment
Share on other sites

Hi Joe, 

Thank you for you reply. 

Yes, in that case runningSum() is my best option. I am running into tow different situations with runningSum(). 

1. runningSum() is working with the signal as is and providing me the right cumulative values

2. In the other cases, I needed to convert them to discreet signal as you suggested to get the right values. 

Do you know why I am having these two different scenarios with runningSum(). 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...