I have time-series data of 10-days for the same time interval as shown in below figure. Here it shows one-hour power consumption for 10 days. Data is sampled at 10 minutes rate.
enter image description here

I need to show this 10-day usage with a single baseline/representative curve. I can calculate baseline curve simply by taking mean/median of these 10 days data, but before that I need to answer following questions:

  1. The baseline should not represent the outlier (abnormal) usage days. Here in figure, we see that day 1 and 2 are following an unusual pattern from the rest of days. I think the usage of these days should not be used in baseline calculation. How should I exclude these days from baseline calculation automatically?
  2. How should I find the most similar usages out of these 10-day usages for my baseline calculation? I think the most/maximum similar usage days represent the days used for baseline calculation.

1 Answer 1


Ad 1. Assuming the measurements at any given time are normally distributed (they shape approximately a bell curve), you could use simple standard deviation to detect outliers. Specifically, for any given time, you can calculate the mean and standard error. Then you calculate the mean sans outliers by taking into account only the measurements that fall at most some pre-set distance from the mean (e.g. given normal distribution, 68% of measurements fall within one standard deviation from the mean).

Pseudo-code example:

# Measurements at time t0 for all 10 days
t0 = np.array([0.1, 0.1, 1.4, .9, 1.25, 1.25, 1.5, 0.1, 0.3, 1.75])

# Get mean and standard error
mean0, std0 = t0.mean(), t0.std()

# Inliers are within one sigma from the mean
inliers = np.logical_and(mean0 - std0 < t0,
                         mean0 + std0 > t0)
# ==> [0, 0, 1, 1, 1, 1, 0, 0, 1, 0]

# And the baseline mean at time t0 is
baseline0 = t0[inliers].mean()
# ==> 1.02

Ad 2. You can find the most similar days to the baseline by using any appropriate distance measure (i.e. for time series: Euclidean or dynamic time warping). The result, then, consists of those days where distance is the least.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.