Conder, J.A. Fitting multiple Gaussian, Hubbert, or other bell curves to a time series, submitted to *Mathematical Geosciences*, Dec 30, 2013.

This function will fit multiple Gaussians or logistic derivatives (“Hubbert curves”) to a time series. It jointly fits them in a least squares sense, using the algorithm explained in the above manuscript. This is a more robust and accurate (and somewhat easier to use) function than the previously published function for Anderson and Conder, 2011. The function was written in Matlab ver. R20131 (Mac).

Usage:

*>> **[Ppre, p, RMSE, pseed] = multibells(t,P,n);*

The function requires three inputs: *t* is time (or other independent variable). *P* is the data to be fit by *n* bell curves. The function defaults to Gaussians, but will fit logistic derivatives by including the argument ‘Hubbert’ or ‘logistic’ as an additional input.

Up to 4 outputs: *Ppre* is a vector of predicted data. *p* contains the parameters (*mu, sigma, A*) of the best fitting *n* curves. *RMSE* is the root mean squared error and *pseed* contains the parameters of the seed curves. An example script, *fit_bells_example.m*, is included.

Jan 3, 2014

James Conder

]]>Anderson and Conder, 2011, Discussion of Multicyclic Hubbert modeling as a method for forecasting future petroleum production, Energy and Fuels, dx.doi.org/10.1021/ef1012648.

This function uses a statistical F-test to determine the likelihood that an observed improvement of a fit to data warrants the use of additional parameters. The function was written in Matlab ver. R2010b (Mac). The “.txt” extension is for ease of distribution and should be removed for use.

Usage:

*>> [ p ] = ftest(n,np1,np2,chi1,chi2)** *

The function requires five inputs: *n* is the number of data to be fit. *np1 *&* np2* are the numbers of free parameters used in the two models. *chi1* and *chi2* are (normalized) sums of the squares of the misfits to the data for the two models.

One output, *p*, is returned*.* *p* is the probability (between 0 and 1) that the improvement of the fit is due to chance. Therefore a small value of *p* means a high confidence that the additional parameters are warranted.

Caveat emptor.

March 10, 2011

James Conder

]]>Usage:

>> [Ppred params rmse] = fit_multicycle(time,prod,nk,nseeds)

The function requires four inputs: time, prod, nk, nseeds. prod and time are vectors of production and associated time stamps. nk is the number of desired curves. nseeds is the number of random seed trials. The greater number of trials, the more likely the program will find a global minimum, but at the expense of time. More curves will generally require a non-linearly increasing number of seeds.

Three outputs are returned: 1) Ppred: predicted production having the same number of data as actual production. Predicted production is the sum of the curves. 2) params: nk x 3 matrix containing the best fitting parameters, tmax (col.1), pmax (col.2), and a (col.3), for each curve. 3) rmse: root mean square error for the model production curve relative to the actual production.

Note: It is not only possible but, quite likely for physically unrealistic parameters (e.g., negative production) to arise when asking for more curves than the data warrant.

For a quick comparison of actual and model production:

>> plot(time,prod,time,Ppre)

Caveat emptor. James Conder

]]>