thanks to Jerry S.
Once upon a time I managed to get a spreadsheet up and running that plotted the distribution of returns.
(The spreadsheet is described here.)
That spreadsheet had a macro which counted the number of returns in each of a collection of return intervals (or bins)
>Huh?
You stuck in a thousand returns running from, say, -20% to +50%, and the spreadsheet would divide the interval
-20% to 50% into a hundred or so bins and determine how many of the thousand returns were in each interval (or bin) and ...
>And plotted them?
Exactly. You click a button and while you sip your coffee, a macro did the counting.
However, because of my limited experience with Excel ...
>And creeping senility?
... I didn't realize that
there was an Excel command FREQUENCY(returns, bins) which did all this
>Didn't realize? Shame on you!
Pay attention.
I changed the spreadsheet described in the link above and also the download spreadsheet described
here to include a plot of the return distribution using that neat
FREQUENCY command.
The latest download spreadsheet ...
>Until you change it.
Uh ... yes. The latest download spreadsheet gives pretty pictures - something like this
|
|
>So, how do you use this frequency thing?
Okay, suppose you have a bunch of returns (or any other numbers!)
in cells A3 to A12 and the bins in column B ... as in Figure 1
- Select cells from C3 to C13 with your mouse.
- Type: =FREQUENCY(A3:A12,B3:B12)
- Press three keys simultaneously: Ctrl+Shift+Enter
Cells C3 to C13 will (compliments of the FREQ-function!) give the number of returns which lie in the various bins:
R<= -5%, -5% < R <= -4%, -4% < R <= -3%, ... and finally R> 4%
(You may want to put appropriate labels on a plot as I've done in column D.)
>That FREQ-function in C3:C13 has one more cell than the bins in B3:B12 !
Yes, because FREQENCY counts the number less than the smallest bin and those greater than the largest bin and, besides,
ten bin numbers define eleven intervals and ...
| Figure 1
|
>Yeah. Nice, but what if I have 1000 numbers and want to count the number in, say, 10 bins.
Sorry 'bout that. Yes, you can have as many bins as you like ... so Figure 1 is misleading.
For example, you might have 1000 stock returns in column A (from A3 to A1002) and 10 bins in column B (from B3 to B12)
so you put, into column C (into C3 to C13, one more than the number of bins) =FREQUENCY(A3:A1002,B3:B12)
... with the magic Ctrl+Shift+Enter technique so it'll appear as {=FREQUENCY(A3:A1002,B3:B12)} in each cell of column C.
|