# Calculate the rate of growth of a signal over a condition

## Recommended Posts

Hi,

I have a signal that grows and then decreases over a condition. I would like to calculate only the average rate of growth, that is from the start value to the maximum. The signal does not grow monotically, which means that the rate locally decreases before the maximum is attained.

I tried to calculate the rate with this formula, but Seeq would not accept it:

\$signal_start = \$signal.aggregate(startValue(), \$condition, middleKey(), 0s)

\$signal_max = \$signal.aggregate(maxValue(), \$condition, middleKey(), 0s)

\$rate = (\$signal_max - \$signal_start)/(\$signal.maxKey(\$condition) - \$signal.startKey(\$condition))

Would you have any suggestion how one could do this without using the derivative() function? Thank you very much in advance for your answer.

##### Share on other sites

• Seeq Team

Hi poeu,

Here's one method for doing what you want:

```\$max = \$signal.aggregate(maxValue(),\$condition,maxKey()).todiscrete()
\$start = \$signal.aggregate(startValue(),\$condition,maxKey()).todiscrete()
\$time = timesince(\$condition, 1min)
(\$max-\$start)/\$time```

In this formula, I'm first calculating the maximum value within the condition and storing that at the timestamp where the maximum was found. I then take the start value an also put that at the max key. Finally, I use timesince to get the calculated time (you can change the units depending on how long your capsule is) at that max timestamp. Note that your condition will need to have a maximum duration so you may need to add a \$condition.removelongerthan(40h) or equivalent prior to the above formulas if your condition does not already have a max duration.

##### Share on other sites

Thank you very much for the quick answer!