Trend Prediction and Distributed Pattern Matching for M2M Data