Creating Leslie matrix using SciPy

The top row containing fecundity rates and remaining rows with survival rates at valid transitions a Leslie matrix it models population projection with discrete time periods and age classes.

Linear Algebra Updated 28 May 2025 2 min read

Overview

  • For a given species, when the capability of reproduction at each age class and their survival rates at discrete intervals are known the information can be applied to the current population data to arrive at the future population levels.
  • Leslie matrix is a Population Projection Matrix which aids in visualizing population growth of a species of discrete age classes at discrete time intervals.
  • Leslie matrix was first introduced by the Scottish Physiologist Patrick Holt Leslie as part of his population studies of certain species in his pioneering work "On the use of matrices in certain population mathematics".
  • In a Leslie matrix, first row represents the capability of reproduction of different age classes of a species followed by the remaining rows representing the survival probilties at different age classes.
  • In a Leslie matrix the second rows to the last rows represent the survival probabilities as a species transition from one age class to another age class. Invalid transitions are marked with zero probabilities.
  • The SciPy function leslie() accepts the fecundity coefficients and survival rates as parameters and returns the Leslie matrix.

Example

  • For a specific species the age classes are infants, juveniles and adults and their reproduction capacity is found to be 0, 2.5 and 1. Their survival rates are given by 0.4 and 0.8. Leslie matrix for the above fecundity and survival data is found by calling scipy.leslie(). The population projection for the period t1 is obtained by multiplying the Leslie matrix with the t0 population which is a column vector. The resultant t1 population projection also is a column vector.
  • Over certain number of iterations the lambda(λ) value becomes stable and the t+1 populations grow in a stable manner because of the constant lambda(λ) value. In this example the lambda value becomes 1.132502 at iteration 33 and remains the same afterwards.
python
# Example Python program that finds the Leslie matrix for a

            # population with a given fecundity and survival rates

            # using the leslie() function of the scipy.linalg module

            import numpy

            import scipy.linalg as sclg

fecundityVals = [0.0, 2.5, 1]

            survivalRates = [0.4, 0.8]

# Create the Leslie matrix

            leslieMatrix = sclg.leslie(fecundityVals, survivalRates)

            print("Leslie matrix:")

            print(leslieMatrix)

# Create a column vector representing the current population

            t1p             = numpy.array([[1000, 400, 240]]).T

            print("Initial population(t0):")

            print(t1p)

timePeriods = 6 #(including t0)

            for timePeriod in range(1, timePeriods):

                tnp = leslieMatrix @ t1p

                print("Population at t%d"%timePeriod)

                print(tnp)

                lambdaVal = tnp.sum()/t1p.sum()

                print("λ=%f"%lambdaVal)

                t1p = tnp

Output

Output
Leslie matrix:

            [[0.  2.5 1. ]

             [0.4 0.  0. ]

             [0.  0.8 0. ]]

            Initial population(t0):

            [[1000]

             [ 400]

             [ 240]]

            Population at t1

            [[1240.]

             [ 400.]

             [ 320.]]

            λ=1.195122

            Population at t2

            [[1320.]

             [ 496.]

             [ 320.]]

            λ=1.089796

            Population at t3

            [[1560. ]

             [ 528. ]

             [ 396.8]]

            λ=1.163296

            Population at t4

            [[1716.8]

             [ 624. ]

             [ 422.4]]

            λ=1.112041

            Population at t5

            [[1982.4 ]

             [ 686.72]

             [ 499.2 ]]

            λ=1.146613