WEBVTT

00:02.000 --> 00:03.854
You might remember your high-school maths
teacher

00:03.869 --> 00:06.419
asking you to draw a line of best fit
through a scatter plot.

00:07.271 --> 00:10.088
But there’s a bit you probably weren’t
taught.

00:10.591 --> 00:12.944
What happens when the data come from the
real world?

00:13.088 --> 00:14.523
There’s noise, there are outliers,

00:14.538 --> 00:17.193
and the errors don’t always fall in a neat
bell curve.

00:18.393 --> 00:20.282
Pranab Kumar Sen ran into that problem

00:20.297 --> 00:22.057
with his sister’s blood chemistry data.

00:22.236 --> 00:24.368
The numbers stubbornly refused to look
normal.

00:24.871 --> 00:26.828
That helped inspire the work behind his

00:26.879 --> 00:28.117
1968 paper,

00:28.133 --> 00:31.217
building on an idea Henri Theil published in
1950.

00:31.930 --> 00:34.016
The usual least-squares line can be pulled

00:34.031 --> 00:35.954
around by a few extreme points.

00:36.098 --> 00:37.893
Theil–Sen gives you another way to fit it.

00:38.396 --> 00:39.959
And I’ll show you how with tokens,

00:39.975 --> 00:41.750
string and a pair of dice.

00:42.188 --> 00:45.497
I’m going to put a token down on this
table for each point in my dataset.

00:45.544 --> 00:47.215
Roll two dice to pick a tag.

00:47.819 --> 00:50.594
The blue die gives the tens, the pink one
the ones.

00:50.919 --> 00:52.440
Roll again for a second tag.

00:52.684 --> 00:54.402
Stretch a string between those two tags.

00:54.495 --> 00:55.621
The angle gives you a slope.

00:55.947 --> 00:57.409
Now do that several times.

00:57.793 --> 01:00.486
Some strings slope sharply, and one even
goes downhill.

01:01.183 --> 01:03.632
Put these five slopes in order and take
the middle one.

01:03.957 --> 01:06.465
It’s the third, about zero point four
seven.

01:06.667 --> 01:07.651
We’ve got the tilt.

01:08.374 --> 01:10.159
But how high should the line sit?

01:10.765 --> 01:13.212
Slide every token to the left, along that
same tilt.

01:13.935 --> 01:16.393
Where each token lands is one vote for the
height.

01:17.116 --> 01:19.737
There are thirty-six tokens, so find the
two in the middle.

01:20.460 --> 01:23.667
Put the line halfway between them, and keep
the same tilt.

01:23.750 --> 01:24.956
Notice what didn’t matter.

01:25.573 --> 01:28.279
Once the points were laid out, I could
have had more tokens on the table

01:28.289 --> 01:29.774
without rolling the dice any more.

01:30.809 --> 01:33.710
What sets the number of rolls is how many
pairs we try.

01:34.013 --> 01:37.091
A few points were far away, and the line
still went through the middle of the

01:37.101 --> 01:37.622
pack.

01:38.239 --> 01:40.595
Now swap the tokens for dots on graph
paper.

01:41.167 --> 01:44.129
Pick two dots at random and draw a straight
line between them with a

01:44.139 --> 01:44.626
ruler.

01:45.358 --> 01:47.563
Do that a few times, then take the middle
tilt.

01:48.179 --> 01:51.060
You can try this yourself on any data where
you’re looking for a straight-line

01:51.070 --> 01:52.042
relationship.

01:53.512 --> 01:54.752
If you enjoyed this video,

01:54.836 --> 01:57.522
you might enjoy
Anyone Can Do Data Science.
