'Simulate an ARMA
Parameters
nsample : int or tuple of ints
If nsample is an integer, then this creates a 1d timeseries of
length size. If nsample is a tuple, creates a len(nsample)
dimensional time series where time is indexed along the input
variable ``axis``. All series are unless ``distrvs`` generates
dependent data.
scale : float
standard deviation of noise
distrvs : function, random number generator
function that generates the random numbers, and takes sample size
as argument
default: np.random.randn
TODO: change to size argument
burnin : integer (default: 0)
to reduce the effect of initial conditions, burnin observations
at the beginning of the sample are dropped
axis : int
See nsample.
Returns
rvs : ndarray
random sample(s) of arma process
Notes
Should work for n-dimensional with time series along axis, but not
tested yet. Processes are sampled independently.'

def generate_sample(self, nsample=100, scale=1.0, distrvs=None, axis=0, burnin=0):

    if (distrvs is None):
        distrvs = np.random.normal
    if (np.ndim(nsample) == 0):
        nsample = [nsample]
    if burnin:
        newsize = list(nsample)
        newsize[axis] += burnin
        newsize = tuple(newsize)
        fslice = ([slice(None)] * len(newsize))
        fslice[axis] = slice(burnin, None, None)
        fslice = tuple(fslice)
    else:
        newsize = tuple(nsample)
        fslice = tuple(([slice(None)] * np.ndim(newsize)))
    eta = (scale * distrvs(size=newsize))
    return signal.lfilter(self.ma, self.ar, eta, axis=axis)[fslice]
