mhurk / marathon

Simulation of distribution of runners on a marathon course
0 stars 0 forks source link
animation marathon python simulation

GitHub Created At GitHub repo file or directory count GitHub code size in bytes GitHub language count GitHub last commit

Marathon Simulation

Simulation of distribution of runners on a marathon course. Simulated for full and half marathon only, not for other distances like 1/4 marathon or business run.

I estimate the number of finishers at around 260 per minute during the hour after 200 minutes from the start of the full marathon. So for a start at 10:00 this translate to 260 runners per minute from 13:20 - 14:20.

Moving histogram and finishers over time

image Screenshot from moving histogram (top left) and the number of finishers as function of time for full and half marathon, and for the sum of these distances.

Animated heatmap

image Screenshot from an animated heatmap for full distance.

Animated heatmap half and full marathon combined

Number of runners in the simulation is changed to 10% of actual starts to limit the file size. With all runners a >350 Mb html file is created. That runs remarkable smooth on a browser but adds no value to the visualization. image Screenshot from an animated heatmap for both distances

Reference marathon

As 260 finishers per minute seems quite a lot to me I made a reference (as suggested by @CanCakiroglu) for a previous marathon in Eindhoven. In 2023 the start for the full marathon was at 10:00 and the half started at 14:00 in the afternoon. I don't exactly know the number of runners for that edition but I used the same numbers as for the 2024 edition. Below graph shows the finishers over time. In the steepest part the number of runners crossing the finishline is approximately 145 per minute. Significantly lower that the predicted number for the 2024 edition.

Number of finishers over time for the start schedule as used in 2023.

Comparison

In order to compare the number of finishers over time the growth rate, maximum groth rate, and Full Width at Half Maximum (FWHM) was calcualted. The growth rate essentially tells how fast runners are finishing at any given point in time. The peak growth rate shows the maximum at which runners are crossing the finish line. FWHM shows the time window over which the majority of the runners are finishing, helping race organizers understand congestion patterns at the finish line.

Below graphs show this information for a reference marathon where the half marathon starts 4 hours (240 minutes) after the full marathon. In the 2024 marathon the start between full and half is 90 minutes. For both editions calculation was done with 6000 full marathanon runners in a 10 minute start wave, and 17500 half marathon runners in 5 start waves, every 10 minutes.

2024 Marathon Reference Marathon
image image

Note that the y-axis of reference and 2024 marathon are not the same

File description

Several files are located in the source directory. Output of graphs and animation (HTML) are located in the images directory. Filenames of the output is equal to the python file, only a different exetnesion and in some cases additional info.

Function of files in source: File name Description Example output
(in /images)
finishers_over_time_analysis.py The graphs used for comparing effect on finishers over time of different start times of full and half.
half_and_full_finishers_over_time.py Creates animation of a moving histogram for full and half marathon, together with individual number of finishers over time and combined number of finishers over time
half_and_full_finishers_over_time_reference.py Almost identical to half_and_full_finishers_over_time.py but with marathon parameters for reference marathon, i.e. longer time between starts. Should be combined in a later update.
pace_waves_finishers_over_time_full.py Animation of moving histogram with finishers over time for full marathon. This is a subset of half_and_full_finishers_over_time.py
pace_waves_finishers_over_time_half.py Animation of moving histogram with finishers over time for half marathon. This is a subset of half_and_full_finishers_over_time.py
pace_smooth_finishers_over_time_half Animation of moving histogram with finishers over time for half marathon. Starting in one big start wave with n runners per minute
runners_heatmap_animated_combined.py Animated HTML heatmap of 2024 Marathon Eindhoven with both half and full and correct start times. Number of runners is 10% of actual starts because the size of the resulting file would be too large. This does not run smooth on older machines. Does not matter for visualisation
runners_heatmap_animated_full.py Animated HTML heatmap of 2024 Marathon Eindhoven, full distance
runners_heatmap_animated_half.py Animated HTML heatmap of 2024 Marathon Eindhoven, half distance
real_data_half.py Create animated histogram with real data
import_real_data.py Function to process excel to usable data na
real_and_sim_half.py Compare real data with simulated data of number of finishers over time

As you see, there is no file with standard parameters like number of runners or some functions. See issue https://github.com/mhurk/marathon/issues/4

Getting started

Why is this at the end you may ask? Well, that seems a nice place.

Run pip install -r requirements.txt to retrieve the packages used in the simulation.

You also need ffmpeg to create the animations. Details on how to do this can be found on stackoverflow.

R 4.3.3. was used with lubridate_1.9.3 and fitdistrplus_1.2-1 for determining the distribution, the mean pace, and the standard deviation.