Python function to calculate the slope under certain conditions

Viewed 33

I want to create a function in python which describes the following situation illustrated in the figure- in qualitative manner:

enter image description here

Example 1: The average value of the 15 data points is given as 30% and the intercept b is 10%. ---> The resulted end value is 50% (= 2*30% - 10%) and therefore the obtained slope s would be: s= (end value - intercept)/14 = 2.86%

Example 2: The average value of the 15 data points is given as 60% and the intercept b is 10%.
--- > The resulted end value is 110% and therefore the obtained slope s would be: s= (end value - intercept)/14 = 7.14% The problem in example that the maximum allowed end value is 100%.

The question is: how to calculate the slope where the average value of the 15 datapoints is 60% and not the maximum allowed end value of 100% is not exceeded at the time?

I'm wondering wether there is pandas or numpy functions which handle with such situation. I have a big time series where the desired function must be applied for each 15 data points.

0 Answers
Related