简体   繁体   中英

Heaviside step function for a time series?

I have a time series that shows changing NDVI over time. I was told I need to apply a heaviside step function to my series. How would I go about applying a heaviside step function? Below is my data set. I am not very familiar with step functions but I know made date where the data changes is September 10th, 2017

date       NDVI
24-Jan-16   0.786
25-Feb-16   0.781
29-Apr-16   0.786
15-May-16   0.761
16-Jun-16   0.762
04-Sep-16   0.783
22-Oct-16   0.797
23-Nov-16   0.792
09-Dec-16   0.783
25-Dec-16   0.788
26-Jan-17   0.776
11-Feb-17   0.789
15-Mar-17   0.781
05-Jul-17   0.785
07-Sep-17   0.796
09-Oct-17   0.304
10-Nov-17   0.316
26-Nov-17   0.636

The Heaviside function is zero for negative arguments and one for positive arguments. It sounds like the request is to produce another table that's zero up to September 17 and one afterwards. If your data are arranged as a list of tuples, and already sorted by date, then you could do this:

original = [("24-Jan-16", 0.786), ("25-Feb-16", 0.781)] # and so on
transformed = list()
value = 0
for stamp, ndvi in original:
    transformed.append((stamp, value))
    if stamp.endswith("Sep-17"):
        day = int(stamp[:2])
        if day >= 10:
            value = 1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM