Serving the Quantitative Finance Community

 
User avatar
Sung
Topic Author
Posts: 0
Joined: March 10th, 2003, 10:41 pm

plot pdf and cdf in excel

September 20th, 2005, 8:29 pm

Hi, I am trying to use excel to plot the graph of a cumulative distribution function and probability density function for the daily returns of a particular stock. I looked all over the place but can't seem to figure it out. Do I have to create the frequencies for the returns and plot a histogram? If any excel pros could help me out it would be greatly appreciated.
 
User avatar
Antonio
Posts: 8
Joined: June 30th, 2004, 3:13 pm
Location: Imperial College London
Contact:

plot pdf and cdf in excel

September 20th, 2005, 9:25 pm

Yes, you have to. You define the boundaries for the horizontal axis, and then you can use the Histogram in Tools/Data Analysis
 
User avatar
ZmeiGorynych
Posts: 6
Joined: July 10th, 2005, 11:46 am

plot pdf and cdf in excel

September 21st, 2005, 7:02 am

It is possible, using the functions PERCENTILE(array, value) and PERCENTRANK(array,x, significance)For a non-connected (dots only, no lines) cdf do a scatterplot (with dots only) with your values on the x-axis and their percentile on the y axis. Prettier plots of cdf and density are also possible using the above functions though a bit trickier. Mail me a sample returns vector and I'll post a spreadsheet.PERCENTILEReturns the k-th percentile of values in a range. You can use this function to establish a threshold of acceptance. For example, you can decide to examine candidates who score above the 90th percentile.Syntax : PERCENTILE(array,k)Array is the array or range of data that defines relative standing.K is the percentile value in the range 0..1, inclusive.Remarks If array is empty or contains more than 8,191 data points, PERCENTILE returns the #NUM! error value.If k is nonnumeric, PERCENTILE returns the #VALUE! error value.If k is < 0 or if k > 1, PERCENTILE returns the #NUM! error value.If k is not a multiple of 1/(n - 1), PERCENTILE interpolates to determine the value at the kth percentile. PERCENTRANKReturns the rank of a value in a data set as a percentage of the data set. This function can be used to evaluate the relative standing of a value within a data set. For example, you can use PERCENTRANK to evaluate the standing of an aptitude test score among all scores for the test.Syntax: PERCENTRANK(array,x,significance)Array is the array or range of data with numeric values that defines relative standing.X is the value for which you want to know the rank.Significance is an optional value that identifies the number of significant digits for the returned percentage value. If omitted, PERCENTRANK uses three digits (0.xxx%).Remarks If array is empty, PERCENTRANK returns the #NUM! error value.If significance < 1, PERCENTRANK returns the #NUM! error value.If x does not match one of the values in array, PERCENTRANK interpolates to return the correct percentage rank.
 
User avatar
ZmeiGorynych
Posts: 6
Joined: July 10th, 2005, 11:46 am

plot pdf and cdf in excel

September 21st, 2005, 2:26 pm

OK, there it is. Plot in tab PrettyPlot. The yellow cells (number of bins and range to grab from) can be changed by the user.Basically, you generate the bins, then the value of CDF at a bin border is PERCENTILERANK(ReturnsRange, ThisBinBorderCell), and the density func is just the derivative of the CDF
Attachments
stock_returns.zip
(31.97 KiB) Downloaded 77 times
 
User avatar
ZmeiGorynych
Posts: 6
Joined: July 10th, 2005, 11:46 am

plot pdf and cdf in excel

September 22nd, 2005, 10:06 am

Here is a challenge for those who think highly of their Excel prowess: produce an Area chart with the x axis on log scale (or more generally, with unevenly (arbitrarily) spaced x-axis points). Hint: it ain't pretty...
 
User avatar
Sung
Topic Author
Posts: 0
Joined: March 10th, 2003, 10:41 pm

plot pdf and cdf in excel

September 22nd, 2005, 3:08 pm

The plots look great, that was what I was trying to accomplish. I'm an excel newbie so I am still learning. Many thanks!
 
User avatar
halopsy
Posts: 2
Joined: April 18th, 2005, 3:14 am

plot pdf and cdf in excel

October 5th, 2005, 1:47 pm

easier... just use =frequency( data , bins ).here is an example of distributions returns, not that "normal" indeed...h
 
User avatar
ZmeiGorynych
Posts: 6
Joined: July 10th, 2005, 11:46 am

plot pdf and cdf in excel

October 6th, 2005, 4:23 am

Neat.