traffic_simulation, a Python code which simulates the way cars must wait at a traffic light.

The user can only input the number of 10-second time periods to be simulated.

The code operates with the following internal parameters:


traffic_simulation ( n )


The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.


traffic_simulation is available in a MATLAB version and an Octave version and a Python version.

Related Data and codes:


python_simulation, a Python code which uses simulation to study card games, contests, and other processes which have a random element. Usually, the purpose is to try to predict the average behavior of the system over many trials.


  1. Brian Hahn, Dan Valentine,
    Essential MATLAB for Engineers and Scientists,
    Academic Press, 2009,
    ISBN13: 978-0123748836,
    LC: TA345.V34.

Source Code:

Last revised on 25 November 2022.