'plot the mean function and optionally the scatter of the sample
Parameters
scatter: bool
If true, then add scatterpoints of sample to plot.
ax : None or matplotlib axis instance
If None, then a matplotlib.pyplot figure is created, otherwise
the given axis, ax, is used.
Returns
fig : matplotlib figure
This is either the created figure instance or the one associated
with ax if ax is given.'

def plot(self, scatter=True, ax=None):

    if (ax is None):
        import matplotlib.pyplot as plt
        fig = plt.figure()
        ax = fig.add_subplot(1, 1, 1)
    if scatter:
        ax.plot(self.x, self.y, 'o', alpha=0.5)
    xx = np.linspace(self.x.min(), self.x.max(), 100)
    ax.plot(xx, self.func(xx), lw=2, color='b', label='dgp    mean')
    return ax.figure
