﻿ Vector, the Journal of the British APL Association

# Current issue

Vol.26 No.4

## Volumes

British APL Association

Archive articles posted online on request: ask the archivist.

Volume 25, No.1

• Submitted
• 0.1

# Norman Thomson

## j doesn’t necessarily mean complex!

Although j in J normally means ‘complex’, numbers of the form `7j2` can model other forms of duple such as odd ratios, for example `7j2` can model odds of 7 to 2 (that is 7 to 2 against), from which fractional odds (`fro`) are obtained as

```   fro=.({: % +/)@:+."0 NB. +. transforms ajb to a b
fro 3j1
0.25
```

`%fro` then gives what is returned (winnings and stake) after a successful unit bet. The accumulated fractional odds of a field of three in which the odds offered by a bookmaker are evens, 3-1 and 7-2 is

```   (+/@:fro)1j1 3j1 7j2
0.9722
```

Of course (pun intended!) bookmakers and betting shops see to it that such a sum is never less than 1, the excess over 1 being what the bookmaker creams off as markup or overround. In practice, real probabilities, that is the absolute probabilities of the various horses winning, vary dynamically right up to the final minutes before a race. Real probabilties reflect the many technicalities of racing as a sport such as the assessment of horses, jockeys, trainers, weather, racetrack condition, even insider trading and corruption, all of which lends a certain naïvety to the fact that some of the observations on which this article is based are derived from the single sets of static odds quoted in the racing pages of daily newspapers. However, broad conclusions can be drawn, for example that in UK horse racing overround seems to average between 25% to 40%. (It goes without saying that should any reader discover a race card for which the `+/@:fro` is less than 1, he or she should immediately raise every possible penny to place bets on all horses in multiples of `fro` and even more importantly should as a matter of duty contact me urgently!)

Add a couple of horses to the above field to make matters more realistic :

```   (+/&:fro) fld=.1j1 3j1 7j2 5j1 8j1
1.25
```

giving an overround of 25%. Thus if bets are placed in the proportions `fro fld` then the cost of betting on all horses will be 1.25 for an assured return of 1 and an assured gain to the bookmaker of 0.25.

Assuming that the bookmaker’s quoted odds reflect his view of the relative probabilities of the horses winning the race, the underlying true odds are:

```   to=.(%+/)&:fro       NB. true odds
to fld
0.4 0.2 0.1778 0.1333 0.08889
```

(Technical note: the hook `%+/` normalises a list so that the total of its elements is 1.)

`to` also demonstrates the extent to which the bookmaker downgrades odds in order to achieve overround, e.g. the horse quoted at evens has in fact a probability of 0.4 of winning the race. Also the returns (that is, including the original stake) multiplied by the true odds remain the same whichever horse wins the race :

```   (to * %@fro)fld
0.8 0.8 0.8 0.8 0.8
```

namely the reciprocal of the overround. The bookmaker accepts bets to create a book, on which he reckons to make the overround as profit whatever the outcome of the race.

Random real probabilities totalling 1 are generated by

```   rnd=.?@#&0       NB. random uniforms in {0,1}
rrp=.(%+/)@:rnd  NB. random real probabilities
rrp 5
0.176 0.28 0.047 0.232 0.265
```

Using these and a book based on `fld`, the bookmaker’s long-term income and outgoings based on horses winning with random probabilities are given by

```   book=.40 20 18 13 9
(+/book),+/book*(rrp 5)*%fro fld
100 79.85
```

Significant risk to the bookmaker arises only if both his book and the real probabilities change. Bookmaker’s arithmetic is a continuous process with input parameters: current book, real probabilities, current actual odds in which he strives to adjust his quoted odds in order to keep the book in balance, and thereby his profits secure. Incomings and outgoings can be formalised in a verb whose left argument is `book;real probabilities`, and whose right argument is `current actual odds`. A balanced book would be simply a multiple of the real probabilities. The example below shows how real probabilities make little difference to the bookmaker’s expectations even if public assessment of the race shifts dramatically in favour of the outsider :

```   inout=.dyad : '(+/>{.x),+/*/(>x),%fro y'
book_rp=.40 20 18 13 9;0.2 0.1 0.1 0.1 0.5
book_rp inout fld
100 80.4
```

However, suppose that the outsider attracts a large number of bets :

```   book_rp=.40 22 18 13 50;0.2 0.1 0.1 0.1 0.5
book_rp inout fld
143 265.7
```

This gives the bookmaker a projected loss of 123. His options are (1) to sustain his previous belief in the relative probabilities but reduce exposure to the new favourite by reducing its quoted odds, in the hope that future bets on the other horses may help to recoup his losses:

```   book_rp=.40 22 18 13 0;0.2 0.1 0.1 0.1 0.5
book_rp inout 1j1 3j1 7j2 5j1 1j2
93 40.7
```

or (2) to accept the new real probabilities and requote all his odds based on these. The primitive verb `j.` transforms `a b` to `ajb`, that is fractions back to odds:

```   (j./@:(%/,-.))0.78
0.78j0.22
```

(The hook `,-.` returns a fraction joined to its 1s complement)

However, it is more satisfactory to have odds in the form `1jx` or `xj1` so define

```   odds=.monad :0
t=.%/y,1-y
if.t>1 do.r=.>.1,t
else. r=.<.(%t),1 end.
r=.j./r
)
odds"(0)0.5 0.25
1j1 3j1
```

(Note: Any rounding favours the bookmaker which seems quite reasonable given that odds can never be a scientifically precise measure.)

The bookmaker might choose to revise his true odds and apply an overround of about 25% to give

```   odds"(0) 0.2 0.1 0.1 0.1 0.5*1.25
3j1 7j1 7j1 7j1 1j2
```

It is not suggested that bookmakers carry out any such arithmetic formally, although the above presumably models roughly the nimble calculations which they instinctively perform.

## Beating the bookie

Given the inherent bias in favour of the bookmaker, are there any ways by which the better can possibly turn the situation to his advantage? First assume that he has some technical knowledge of which he feels reasonably assured and believes to be superior to that of the bookmaker.

Since `%fro fld` gives the returns for a unit bet the returns for any list of bets are

```    rets =.[*%@:fro@]   NB. left argument = bets
1 1 1 1 1 rets fld
2 4 4.5 6 9
```

Suppose now that as a matter of judgement the better believes that the race will certainly be won by one of the two favourites with probabilities in proportion 3:2. His expected returns for a bet which reflects this are

```   6 4 0 0 0 rets fld
12 16 0 0 0
```

that is, for a total outlay of 10 he will achieve a return of either 12 or 16 or 0. His expectation, using true odds, is (0.4×6) + (0.2×12) = 4.8 which would give the bookmaker an expected gain of 5.2. However the expectation based on his own judgement is (0.6×12) + (0.4×16) = 13.6, and so if he has complete confidence in his judgement and behaves rationally, it would be senseless for him not to bet, nor indeed would he be unhappy if one of the unbacked horses won, since he would still have achieved value for his money in the same sense that an insurance policy on which no claim is made has nevertheless provided valuable cover.

Alternatively the better might choose to use the judgement of others, e.g. newspaper tipsters. What are the net gains or losses resulting from a unit bet on every tipster recommendation for a given day? On a day in which 20 races were run and four winners were tipped at 4-1, 11-4, 7-2 and 4-1, the net gain achieved for unit bets placed by following a tipster was given by :

```   tips=.-~+/@:(1&rets)@ ]
20 tips 4j1 11j4 7j2 4j1
_1.75
```

that is an overall loss of -1.75. Empirical evidence using the racing correspondents of the Times and the Daily Telegraph shows that following tipsters’ advice consistently is very rarely profitable, and even then only when a winner happens to be picked at unusually long odds.

Turn now to manipulating probabilities, are there any techniques based on probability alone which can swing the bias away from the bookmaker towards the better? Such a possibility is demonstrated by the so-called Martingale in which a stake is progressively doubled for a losing bet and betting stops on a winning one. In a fair game at evens, e.g. coin tossing with bets on a tail, a tail is bound to occur eventually, at which point there is a net gain of one original betting unit. The problem is that the certainty of winning requires unbounded available capital.

## Fantasy betting

The safest way for the novice to take his first steps into the world of betting is to use his computer to estimate and simulate the forces he will encounter in the real world in which real money changes hands. First generate random uniform integers using Interval Index `I.` to transform each of the numbers in `rnd` into a serial number of one of the intervals defined by the left argument.

```   wrnd=.(+/\)@[  I. rnd@]   NB. weightd random integers
>:(to fld)wrnd 10
1 3 3 3 1 4 1 1 2 3
```

thus in 10 reruns the first and third horses each won 4 times, the second and fourth horses won once and the fifth horse not at all. To count frequencies arising in such runs say

```   +/"1 (i.#fld) =/ (to fld)wrnd 10
2 3 4 0 1
```

which can be consolidated in a verb where the right argument is the number of reruns :

```   rerun=.dyad :'+/"1 (i.#x) =/ (to x)wrnd y'
fld rerun 20
10 5 2 2 1
```

that is the favourite won exactly half of the time in the above simulated sequence.

A simulated race with between 5 and 17 runners each of which consists of drawings from a negative exponential distribution with mean 1.25 is given by

```   sortd=.{~\:
rne=.[ * ^.@%@rnd@]  NB. random negative exponential
odds"(0)0.0475>.sortd (%+/)1.25 rne 10
5j1 5j1 6j1 8j1 9j1 10j1 12j1 12j1 14j1 20j1
```

(Note : There is no special reason for using the negative exponential distribution other than that it appears empirically to give lists of odds which look tolerably similar to those actually printed daily in the sporting pages. `0.0475>` is to ensure that no odds are greater than `20j1`.)

It is convenient to head each list with the sequence number of the randomly drawn winner (favourite = 1, etc.).

```rrace=.monad :0                  NB. random race
r=.odds"(0)t=.0.0475>.sortd (%+/)1.25 rne 5+?13
r=.(>:(+/\ (%+/)t) I. rnd 1),r   NB. join random winner
)
rrace 10
2 1j1 3j1 12j1 13j1 17j1 18j1 20j1 20j1 20j1 20j1 20j1 20j1
```

A random race card with 3 races is then given by

```   rrcard=.monad : '>rrace each 5+?y#13'
rrcard 3
3 2j1 2j1 6j1  6j1  7j1 19j1    0    0    0    0    0    0
1 2j1 3j1 9j1 11j1 14j1 15j1 16j1 17j1 19j1 19j1 19j1 19j1
1 1j1 5j1 5j1  7j1 10j1 18j1 19j1 19j1 19j1 19j1    0    0
```

## Betting methods

Various methods can be employed when a bet on a single race is placed, for example the favourite can be backed, or a pin stuck in the race card, or a horse chosen at random but with weights applied based on the quoted odds. These three possibilities are described respectively in

```method=.dyad : 0
r=.i.0 [ i=.0
while.i<#x do. t=.i{x               NB. loop through races
select. y
case. 1 do. b=.1                  NB. bet on favourite
case. 2 do. b=.>:?<:#t            NB. stick a pin in race card
case. 3 do. b=.>:(fro }.t)wrnd 1  NB. random, wts=odds
end.
if.(b={.t)do. r=.r,(<:{.t){%fro }.t NB. win
else. r=.r,0 end.                    NB. lose
i=.i+1 end. r
)
```

The experiments which follow are based on a hypothetical race meeting where between 5 and 17 horses ran in each of 1,000 races, with a simulated 25% overround.

```   rc=.rrcard 1000
+/"1>(<rc)method each 1 2 3
752.8 503.3 772
```

gives the total winnings on a unit stake in each race. Thus for each method 1,000 units of were staked, and apart from method 2, the totals in the above run converge towards a value of 800. Repeated reruns with further race cards show consistency in the case of methods 1 and 3 but considerable variability with method 2, which rarely comes even close to 800 – in other words, random selection is likely to be a worst case strategy in the long run! That said, the methods were applied to three real race meetings at Ripon, Carlisle and Newton Abbot with 7, 7 and 6 races respectively with results :

```Ripon: 9 0 0   Carlisle: 7.375 16 0   Newton Abbot: 11.1 0 3.75
```

showing that even pin-stickers can have their lucky day!

## Betting systems

Simulated race cards provide the opportunity for testing out betting systems, that is betting sequences in which stakes change dynamically according to previous results. One such system is due to the 18th-century mathematician d’Alembert. Applying this system, the size of the stake is increased by 1 in the case of a losing bet and decreased by 1 in the event of a winning bet. A zero stake is replaced by the original stake. For example, with an initial bet of 5 and a sole win of 5 on the fourth race out of six, the succession of bets was 5, 6, 7, 8, 7 and 8, a total of 41 for a return of 8×5=40 and an overall loss of 1. The following verb simulates the sequence of stakes :

```   dalem=.dyad :0                     NB. x is stake, y is returns list
r=.x [ i=.1
while.i<#y do.                        NB. loop through returns
if.(0={:r)do.r=.(}:r),x               NB. if 0 restore initial stake
else.r=.r,({:r)+_1++:0=(<:i){y end.   NB. raise or lower
i=.i+1 end.r
)
5 dalem 0 0 0 5 0 0
5 6 7 8 7 8
```

Long runs of losers lead to increasingly large stakes developing. Using the ‘back the favourite’ method on the simulated 1000-race card `rc`, the total returned is

```   t1=.rc method 1
+/(*5&dalem) t1
198252.2
```

for total stakes of

```   +/5 dalem t1
256230
```

198,252/256,230 = 77.4% which is little different from straightforward constant bets. The corresponding figures for methods 2 and 3 are 211,035÷445410 = 47.4% and 267065÷331,278 = 80.6%, indicating again the weakness of ‘selecting by pin’. In all cases the figures show how the better runs the risk of a heavy absolute loss using this system when wins are relatively infrequent.

Other systems could be based on patterns of wins and losses for which the primitive verb `E.` is helpful. For example if a constant bet of 5 is made only after observing a ‘win-lose’ sequence, define

```    wl=.3 :'0 0,_2}.1 0 E.y~:0'
wl 1 0 0 0 1 1
0 0 1 0 0 0
```

In this case bets would in the long run be placed only part of the time:

```    +/wl 0~:t1=.rc method 1
185
+/(wl t~:0)#t1
131.33
```

131.3÷185 = 71.0% and the corresponding percentages for methods 2 and 3 were 55.5% and 90.0% respectively. The practical message is that neither of the above systems offers the better much hope of advantage in the long run. However, having so much experimental possibility available at home makes things significantly easier to organise than a day at Aintree or Goodwood, and a good deal cheaper too – have a great day in!

```script began 6:20:22
caching off
debug mode off
cache time 3600 sec