O'Reilly logo

NumPy Cookbook - Second Edition by Ivan Idris

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Predicting pressure with a moving average model

A simple way to model atmospheric pressure is to assume that values dance around a mean μ. We then assume in the simplest case that deviations of consecutive values ε from the mean follow this equation:

Predicting pressure with a moving average model

The relation is linear and in the simplest case, we need to estimate only one parameter—θ. To do so, we will require SciPy functionality. The full code for this recipe is in the moving_average.py file in this book's code bundle:

from __future__ import print_function import numpy as np import matplotlib.pyplot as plt from datetime import datetime as dt from scipy.optimize import leastsq data = np.load('cbk12.npy') ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required