Start Submission Become a Reviewer

Reading: MatCal: Open Source Bayesian 14C Age Calibration in Matlab


A- A+
Alt. Display

Software Metapapers

MatCal: Open Source Bayesian 14C Age Calibration in Matlab


Bryan C. Lougheed ,

Uppsala University, SE
X close

Stephen P. Obrochta

Akita University, JP
X close


The matcal function provides radiocarbon (14C) age calibration in Matlab using the Bayesian highest posterior density (HPD). The function produces a probability distribution function (PDF) of calibrated ages, as well as 1 sigma (68.27%) and 2 sigma (95.45%) probability calibrated age credible intervals, calculated using HPD. Publication ready calibration plots are also produced, with the option to save to disk. Calibration output can be in either Cal BP or BCE/CE (BC/AD), and a reservoir age can be specified if necessary. The user can choose from a number of calibration curves, including the latest version of IntCal.

How to Cite: Lougheed, B.C. and Obrochta, S.P., 2016. MatCal: Open Source Bayesian 14C Age Calibration in Matlab. Journal of Open Research Software, 4(1), p.e42. DOI:
  Published on 08 Nov 2016
 Accepted on 13 Oct 2016            Submitted on 17 May 2016

(1) Overview


Radiocarbon (14C) age calibration is a necessary process for estimating the true age range of a 14C determination. Atmospheric 14C activity (Δ14C) has not been constant throughout history, due to changes in the rate of 14C production in the upper atmosphere, as well as changes in the Earth’s carbon cycle. Simply knowing the 14C activity of a given sample and applying the half-life of 14C is, therefore, in itself not sufficient to determine the true age range; one must also have knowledge of past Δ14C.

Reconstructions of past Δ14C have been carried out using independently dated terrestrial archives, including tree-ring, speleothem and lake records. Additionally, independently dated marine archives have also been used to indirectly reconstruct past Δ14C. The aforementioned Δ14C records can be combined to produce what is known as a calibration curve, a continuous record of past atmospheric 14C activity. The most commonly used calibration curves are produced by the IntCal group of scientists, the most recent versions of which were published in 2013 [1, 2]. The latest calibration curves are IntCal13 (a global atmospheric calibration curve), SHCal13 (a southern hemisphere atmospheric calibration curve) and Marine13 (a calibration curve for the surface mixed layer of the global oceans). All calibration curves include a 1 sigma uncertainty range of possible 14C ages (14C yr BP) corresponding to a certain true age, or calibrated age (Cal yr BP).

14C age determinations produced by radiocarbon laboratories are given in the form of a normal (Gaussian) distribution, whereby mean and 1 sigma values for the 14C age are reported. The age calibration process involves using the shape of the calibration curve and its associated 1 sigma value to produce a probable calibrated age range for the 14C age determination. A number of software tools offering 14C calibration functionality have been authored and are widely used by researchers. Two of the most widely used such tools are the standalone calibration programs Calib [3] and the age modelling software OxCal [4]. Additionally, 14C calibration routines are built into the R-based, open source age modelling software packages Clam [5] and Bacon [6]. More recently, a Python-based, open source 14C age calibration script (IOSACal) has also been written [7].

Many researchers within geosciences and archaeology make use of Matlab when analysing data. Some of these researchers also carry out 14C determinations as part of their work. MatCal provides a 14C calibration function that can easily be implemented into a Matlab-based workflow.

Implementation and architecture

The first methods used for 14C age calibration, including in the earliest versions of Calib, involved using the so called ‘intercept method’, where one essentially uses the calibration curve as a lookup table to find the calibration curve values directly associated with median, 1 sigma and 2 sigma values of the normal distribution of the 14C age determination. Later, OxCal [4] and BCal [8] pioneered 14C age calibration by using the normal distribution of the 14C age determination and the 1 sigma range of the calibration curve to calculate a probability density function (PDF) of calibrated ages, which is subsequently analysed using the Bayesian highest posterior density (HPD) method, resulting in a superior calibrated age range determination [9]. MatCal also employs HPD analysis of a PDF.

The matcal function loads a chosen calibration curve into the Matlab workspace and then linearly interpolates the full range of calibration curve calibrated years to annual resolution. Following Bronk Ramsey [10], an age probability (P) is calculated (Eq. 1) for each annual calibrated year (t), where the normal distribution of the 14C age determination is represented by D ± σD (input variables c14age and c14err), and the calibration curve 14C age for each calibrated year (t) is represented as f(t) ± σf(t). Both the calibration curve 14C data and the user inputted 14C data are converted to F14C space when calculating P(t), which is a more suitable approach, especially for older ages [10].

(Equation 1)

A resulting n by 2 array containing calibrated years and associated probabilities (normalised to between zero and one) is subsequently analysed using the Bayesian highest posterior density (HPD) method in order to calculate the calibrated age probability range associated with the 1 sigma (68.27%) and 2 sigma (95.45%) confidence levels (CL). Specifically, the HPD method is implemented as follows: the aforementioned n by 2 array is sorted by probability, after which a cumulative P is calculated. All calibrated years with a cumulative probability falling between 1-CL and 1 are subsequently selected and sorted by calibrated year, after which all continuous annual intervals of calibrated years represent the discrete HPD confidence intervals. The probability associated with each HPD interval is determined by taking the sum of the probability for all calibrated years within the interval itself. All relevant information is also plotted in a Matlab figure with handle ‘14’ (Figure 1).

Figure 1 

An example of a 14C calibration output plot from MatCal. The red shaded area indicates the 14C age normal distribution. The darker and lighter blue shading respectively indicates the 1 sigma and 2 sigma credible intervals of the calibrated age PDF. The darker and lighter grey shaded areas indicate the calibration curve 1 sigma and 2 sigma confidence intervals, respectively. The green error bars (only shown in the case of IntCal13) indicate the raw 14C data used to construct the calibration curve.

It is also possible to include a reservoir age (R(t) or ΔR) and reservoir age uncertainty (σR) when calibrating a 14C determination, using the input variables resage and reserr. Reservoir age is applied before the calibration process commences, by altering the 14C determination (D ± σD) to Dr ± σr as follows:

Dr=DRandσr= (σD2+ σR2)½

Quality control

MatCal has been tested against the two most commonly used 14C calibration tools, the aforementioned Calib and Oxcal (Table 1). MatCal is found to agree very well with both tools. The very minor differences are most likely due to the slightly different methods used to interpolate the calibration curve. OxCal, for example, interpolates the calibration curve to sub-annual resolution, whereas MatCal interpolates to annual resolution. Seeing as the pre-bomb calibration curves are published in five and ten year resolution, an equal case can be made to apply either annual or sub-annual interpolation. It can be noted that both MatCal and OxCal provide superior calibration for the very oldest dates and/or dates with very large uncertainty, due to the calculation of calibrated age probability in F14C space.

Table 1

14C age calibration in MatCal 2.0, Calib 7.0.0 and OxCal 4.2 and using IntCal13. Calibration results shown are the 1σ calibrated age ranges in Cal yr BP.

14C age MatCal 2.0 Calib 7.0.0 OxCal 4.2

500 ± 30 536 – 514 536 – 514 537 – 513
10000 ± 60 11610 – 11520
11507 – 11326
11610 – 11519
11508 – 11326
11610 – 11519
11508 – 11326
15000 ± 80 18346 – 18109 18345 – 18109 18346 – 18110
25000 ± 100 29177 – 28861 29175 – 28859 29178 – 28860
35000 ± 120 39758 – 39342 39757 – 39339 39760 – 39341
45000 ± 250 48801 – 47953 48792 – 47944 48801 – 47953

Further quality control has been carried out for Matlab in the form of user testing, which has led to the implementation of a number of error and warning messages. For example, if the user attempts to calibrate a 14C age which produces a calibrated age PDF partially exceeding the range of the chosen calibration curve (e.g. <0 cal yr BP or >50000 cal yr BP in the case of IntCal13), a warning message is returned to the command window and also displayed on any subsequent output plots. Furthermore, user interpretable error messages are returned when, for example, an invalid calibration curve name is selected or if invalid and/or not enough input parameters are set.

(2) Availability

Operating system

Any system capable of running Matlab R2012a or higher.

Programming language

Tested as working in Matlab R2012a, likely to work in earlier versions also.

Additional system requirements



The MatLab plotting toolbox is required if the user decides to make use of the plotting functions.

List of contributors

Bryan C. Lougheed (wrote 14C calibration routine, plotting module and manuscript)

Stephen P. Obrochta (wrote input parser and rewrote parts of code to increase compatibility across multiple Matlab versions)

Software location

Archive (e.g. institutional repository, general repository) (required – please see instructions on journal website for depositing archive copy of software in a suitable repository)

Name: Figshare

Persistent identifier: doi: 10.6084/m9.figshare.3380710.v1

Licence: GNU General Public License Version 2

Publisher: Bryan C. Lougheed

Version published: 2.0

Date published: 2016-10-04

Code repository

Name: GitHub


Licence: GNU General Public License Version 2

Date published: 2016-10-04



(3) Reuse potential

The matcal function is very suitable for implementation in a Matlab-based geosciences project. For example, users might want to experiment with rapidly calibrating 14C ages using multiple calibration curves or multiple reservoir ages. Previously, researchers may have had to implement calibration in an external software package, but now it is possible to implement the 14C calibration into a Matlab workflow. For example, one may wish to batch calibrate multiple 14C ages, which can be easily done by calling the matcal function within a loop.

The calibrated age probability density function (calprob) and highest posterior density credible intervals (p68_2 and p95_4) outputs are also ideal for implementation within a geochronological age modelling routine, e.g. Monte Carlo techniques.


Brett Metcalfe is thanked for user testing. The authors acknowledge Maarten Blaauw’s informative webpage at Queen’s University Belfast.

Competing interests

The authors declare that they have no competing interests.


  1. Reimer, P J Bard, E Bayliss, A Beck, J W Blackwell, P G Bronk Ramsey, C et al. (2013). IntCal13 and Marine13 radiocarbon age calibration curves 0–50,000 years cal BP. Radiocarbon 55(4): 1869–1887, DOI: 

  2. Hogg, A G Hua, Q Blackwell, P G Niu, M Buck, C E Guilderson, T P et al. (2013). SHCal13 Southern Hemisphere Calibration, 0–50,000 Years cal BP. Radiocarbon 55(4): 1889–903, DOI: 

  3. Stuiver, M and Reimer, P J (1993). Extended 14C data base and revised CALIB 3.0 14C age calibration program. Radiocarbon 35: 215–30, DOI: 

  4. Bronk Ramsey, C (1995). Radiocarbon calibration and analysis of stratigraphy; the OxCal program. Radiocarbon 37(2): 425–30, DOI: 

  5. Blaauw, M (2010). Methods and code for “classical” age-modelling of radiocarbon sequences. Quat Geochronol 5(5): 512–8, DOI: 

  6. Blaauw, M Christen, J A et al. (2011). Flexible paleoclimate age-depth models using an autoregressive gamma process. Bayesian Anal 6(3): 457–74, DOI: 

  7. Costa, S and Gutiérrez-Roig, M (2016). IOSACal: v0.3. Zenodo. DOI: 

  8. Buck, C E, Christen, J A and James, G N (1999). BCal: an on-line Bayesian radiocarbon calibration tool. Internet Archaeology 7 Available at: 

  9. Telford, R J, Heegaard, E and Birks, H J B (2004). The intercept is a poor estimate of a calibrated radiocarbon age. The Holocene 14(2): 296–8, DOI: 

  10. Bronk Ramsey, C (2008). Radiocarbon dating: Revolutions in Understanding. Archaeometry 50(2): 249–75, DOI: 

comments powered by Disqus