WEBVTT

00:00.780 --> 00:07.230
In this video we will create an interactive histogram with bluntly and Instagram's are useful in cases

00:07.230 --> 00:13.170
where we want to examine the distribution of values and the one major application and finance is to

00:13.170 --> 00:16.230
analyze the distribution of returns.

00:16.230 --> 00:24.240
So we are still imparted the stocks data frame and with the percentage change method we can create the

00:24.270 --> 00:26.580
returns data frame.

00:26.670 --> 00:35.190
So here we have that daily returns for our six stocks and then we can create a histogram and we can

00:35.190 --> 00:41.700
simply do this with the eye plot method and we pass histogram to the kind parameter.

00:41.760 --> 00:42.530
So let's have a look.

00:48.140 --> 00:53.390
So here we have the interactive histogram with Plumlee and.

00:53.420 --> 00:59.650
For example we can select one single stock for example the Apple stock and TV effort.

00:59.660 --> 01:02.390
That distribution of daily returns.

01:02.390 --> 01:08.250
So for example he and the interval from 0 to 0 point two percent.

01:08.450 --> 01:11.980
We have one hundred fifty six occurrences.

01:12.050 --> 01:15.200
So here we have uh the absolute frequency.

01:15.800 --> 01:23.360
And it's actually no surprise uh that the majority of daily returns is around uh 0 percent here.

01:23.360 --> 01:27.380
But we have also some uh value you see on the tails.

01:27.530 --> 01:35.640
So we have one day where we have minus 10 percent roundabout and even uh one day with a minus twelve

01:35.650 --> 01:36.300
percent.

01:36.320 --> 01:39.710
And we have also quite positive days.

01:39.710 --> 01:43.570
So here returns with 8 percent 9 percent.

01:43.910 --> 01:51.650
And we can also compare this this abuse with another stock for example the Coca-Cola stock so we have

01:51.680 --> 01:55.220
both stocks and that seems like that.

01:55.250 --> 01:57.640
The Apple stock is more volatile.

01:58.010 --> 02:06.070
So there's more risk and the more frequency here in the tails and of course we could simply calculate

02:06.090 --> 02:12.850
the variance or the standard deviation to figure this out but uh we can also see this year graphically.

02:12.870 --> 02:17.870
So this is in many cases more intuitive.

02:17.890 --> 02:23.350
However there is one pitfall when comparing many histogram side distributions and politely and I think

02:23.350 --> 02:30.430
you can hardly see it that politely tries to scale and customize the bits of each distribution separately.

02:30.430 --> 02:36.260
So you might see here that in one apple been there actually two Coca-Cola bins.

02:36.520 --> 02:41.700
So the width of an apple in this actually twice the width of a Coca-Cola bin.

02:41.860 --> 02:43.500
And that makes it hard to compare.

02:43.510 --> 02:50.380
But we can set the bin dimensions for all distributions and we can do this by passing a topper to the

02:50.380 --> 02:52.220
bins parameter.

02:52.360 --> 02:59.470
So we have a bins perimeter and we can pass a topper with three values.

03:00.010 --> 03:03.740
So the first value marks the start.

03:03.730 --> 03:11.200
And let's have a look here on the left hand side so the start might be a maybe a minus 20 percent to

03:11.200 --> 03:18.950
get minus 15 percent to get you all values so we have a minus 15 percent.

03:19.490 --> 03:26.700
Then the second value is for the end and maybe we should to see our 10 percent

03:29.800 --> 03:33.830
and then the third value is actually the width of all bins.

03:34.000 --> 03:39.820
And uh here we could choose maybe uh 0.01 percent per bin

03:43.230 --> 03:48.530
and actually this scale and this dimension applies uh for all of this abuse.

03:48.540 --> 03:50.400
So let's run the site here

03:55.500 --> 04:06.990
and let's again have a look here only at uh the Apple stock and let's add also the Coca-Cola stock and

04:06.990 --> 04:12.180
all with the same bin size that is easier to compare both distributions.

04:12.330 --> 04:20.130
So we can see that the Coca-Cola stock has more frequency here in the middle and on the other hand side

04:20.130 --> 04:24.160
of the Apple stock has more frequency here in the States.

04:24.240 --> 04:30.020
So the Apple stock is obviously more risky than the Coca-Cola stock.

04:30.300 --> 04:34.340
And we can also see on the left hand side our y axis.

04:34.530 --> 04:39.050
And here we have absolute uh quantities of frequencies.

04:39.210 --> 04:47.520
And if we have distributions within a different amount of observations then it might be better to actually

04:47.530 --> 04:50.610
normalize um the y axis.

04:50.610 --> 04:54.750
And uh we can do this with repair meter his norm

05:02.290 --> 05:06.350
and we can either pass probability or percentage.

05:06.370 --> 05:08.800
So first of all let's try a probability

05:16.230 --> 05:21.290
and instead of getting the absolute quantities we get here the relative quantities.

05:21.330 --> 05:23.640
Um in terms of probabilities.

05:23.640 --> 05:25.990
So yes 6 percent 5 percent.

05:26.310 --> 05:34.230
And instead of getting your 0 point 0 6 and 0 point 0 5 you can also get uh the percentage terms low

05:34.230 --> 05:40.160
6 and 5 and we get this by passing a percent instead of probability

05:45.880 --> 05:47.200
and that's roughly the So

05:50.480 --> 05:54.680
and here we have now 6 percent 5 percent and so on.

05:54.680 --> 06:01.280
So this was a short introduction to the plotline histogram and I hope to see also in the next video

06:01.310 --> 06:01.610
by.
