MateSim: Monte Carlo simulation of mating





  1. Please read the user's guide. Current version is 1.0.
  2. Input files are optional and applicable for both discrete and continuous traits.
  3. You can add comments at the input files just beginning the lines with the # symbol.


Command line examples


Input file examples


If you use MateSim please cite:
Carvajal-Rodríguez, A. 2018. Monte Carlo simulation for the generation of mating tables. BioSystems 171: 26-30 Doi: 10.1016/j.biosystems.2018.07.001.


  1. Carvajal-Rodriguez, A., 2018. Non-random mating and information theory. Theoretical Population Biology 120, 103-113.
  2. Carvajal-Rodriguez, A., 2019. A generalization of the informational view of non-random mating: Models with variable population frequencies. Theoretical Population Biology 125, 67-74.
  3. Carvajal-Rodriguez, A., 2020. Multi-model inference of non-random mating from an information theoretic approach. Theoretical Population Biology In Press. Doi: 10.1016/j.tpb.2019.11.002.
  4. Gimelfarb, A., 1988. Processes of Pair Formation Leading to Assortative Mating in Biological Populations: Encounter-Mating Model. The American Naturalist 131, 865-884.
  5. Xie, Y., Cheng, S., Zhou, X., 2015. Assortative mating without assortative preference. Proceedings of the National Academy of Sciences 112, 5974-5978.


For any questions about the options of the program you can contact me



This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. See the file "gpl.html" under the "license" directory.
















Return to AC-R home



MateSim is a C++ computer program that implements Monte Carlo simulation models for generating mating tables under discrete or continuous traits. MateSim allows for different processes of pair formation and individual mutual mating propensity or preference models. It includes effects as drift, time dependent behaviour and ageing.
Pair formation
The program implements different processes of pair formation:

1. SR: Sampling with replacement. The availability of individuals for mating is not affected by the previous mating. This scenario corresponds to polygamous species as well to monogamous in which only a fraction of the population individuals mate.

2. I-EM: Individual-encounter mating model (Gimelfarb 1988, Carvajal-Rodríguez 2019). There is only one encounter at a time. If the mating is successful the population frequencies of available individuals are updated. This scenario may be adequate for monogamous species with low population size.

3. M-EM: Mass-encounter mating model. Similar to i-EM but several pairs can be formed simultaneously. As before, the population frequencies are updated after each mating round.

Discrete traits

The trait involved in the mating process is discrete. Given the population frequencies p1 and p2 for female and males, respectively, the expected number of occurrences for the mating i × j in a sample of size n is (Carvajal-Rodriguez 2018)

Q(i,j) = n × p1i × p2j × mij / M

After each mating round, the population frequencies are updated depending on the pair formation model.

Continuous traits

The trait involved in the preference process is continuous. MateSim implements Gaussian or logistic preferences depending on how we parametrize the general preference function

f= exp01Z)

Gaussian preference function

Given an encounter and the preference function value fij, the mating probability for a pair i,j will be

pij = fij / fmax

where fmax is the maximum over the available matings.

Logistic preference function

Given an encounter, consider the logistic variable fi for the female with trait i, then the mating probability of this female is

pi = 1 / ( 1+ fi-1)

Similarly, the mating probability of male j is pj = 1 / ( 1+ fj-1).

Therefore, the mating probability for a pair i,j will be

pij = pi x pj

A key difference between continuous and discrete preference traits is that for discrete traits, the important quantities do not involve individuals but the counts of matings of each phenotypic class. In the continuous case however, we may consider each individual separately and therefore it makes sense to consider individual characteristics as impatience or ageing.

Decreasing in time choosiness (impatience for mating)

Under this option, single individuals become impatient as time passes and an increasing number of marriages were performed, especially if neither polygamy nor divorce is allowed (Xie et al. 2015). Therefore as time passes the individuals become less choosy proportional to the number of marriages already performed.


It seems realistic to consider that independently of the mating trait, the mating probability of an individual decreases with age. This may occur because the individual becomes old, sick or sterile or simply has not enough energy to invest in mating. We model the aging process regarding to mating, by means of the Weibull distribution. This distribution is versatile and adequate for modeling time-to-failure processes. In our context, the survival function R(t) represents the probability that at age t an individual is not yet sterile.

R(t) = Prob(T>t) = exp[-((t - γ)/α)β]

An individual is considered sterile at time t when UR(t) where U follows an uniform(0,1). If the individual happened to be sterile then it is discarded from the population.


A. Carvajal-Rodriguez - Departamento de Bioquímica Genética e Inmunología - Universidad de Vigo. ( Last update: December 2019)