# The Olympic Heptathlon

#### Question

The Women's Olympic Heptathlon is comprised of seven events in which competitors are awarded points based on their performance. The points are awarded according to the following formulas for the different groups of events (running, jumping, throwing). The formulas are devised to award 1000 points for some reference performance and 0 points at some minimum level of performance.

• Running: $P = a(b-T)^c$ (time, $T$ in seconds)

• Jumping: $P = a(H-b)^c$ (height, $H$ in cm)

• Throwing: $P = a(D-b)^c$ (distance, $D$ in m)

The coefficients for these formulas are given for each event in the table below.

Event$a$$b$$c$
100 m hurdles9.2307626.71.835
High jump1.84523751.348
Shot put56.02111.501.05
200 m4.9908742.51.81
Long jump0.1888072101.41
Javelin throw15.98033.801.04
800 m0.111932541.88

At the 2016 Rio Olympics the competitors awarded medals performed as given in this table.

EventNafissatou ThiamJessica Ennis-HillBrianne Theisen Eaton
100 m hurdles13.56 s12.84 s13.18 s
High jump1.98 m1.89 m1.86 m
Shot put14.91 m13.86 m13.45 m
200 m25.10 s23.49 s24.18 s
Long jump6.58 m6.34 m6.48 m
Javelin throw53.13 m46.06 m47.36 m
800 m2 min 16.54 sec2 min 9.07 sec2 min 9.50 sec

Write a Python program to store the coefficients in a dictionary, keyed by the event name, and use another dictionary to store the competitors' results in each event. Use these data structures. Define functions to calculate the points a given performance is awarded in each event, and use them to calculate the total number of points for each of the competitors.

Bonus exercise: Generate the following diagram as an SVG image.

Hints: the following function returns a point on the unit circle a fraction i/n of the way round from a reference direction defined by phase (use phase=0 to use the $x$-axis as this refefence direction).

def get_point_on_unit_circle(i, n, phase=0):
return np.cos(2*np.pi*i/n - phase), np.sin(2*np.pi*i/n - phase)


Find the distances along each event axis in pixel coordinates with:

r_pts = r * (event_points - min_points) / (max_points - min_points)


where min_points and max_points correspond to the centre and outer limit of the chart axes respectively (500 and 1300 are good choices here) and r is the radius of the chart in pixels.

This figure was inspired by @kala_blanc's visualization on Twitter.

#### Solution

To access solutions, please obtain an access code from Cambridge University Press at the Lecturer Resources page for my book (registration required) and then sign up to scipython.com providing this code.