|
|
| File Information |
| Description |
This program assumes you have created an arbitrary PDF and can represent it via an arbitrarily high number of x,y points.
As an aside, if you only have observations from the PDF, I find the combination of ksdensity and a smoothing spline are a great way to create cfit function that you can then run feval on and then generate the arbitrarily high x,y pairs mentioned above.
Here's the surprisingly simple part: imagine this, take your y (heights) and lay them end-to-end? what you then have is a line composed of ?segments? each of length y(x). Now generate a uniform random number of the range of 0 to the length of the segmented line (e.g. sum(y)*rand()). Now, wherever that uniform random number falls, look down at which y ?segment? you landed on and generate the corresponding x as the output!
I wish I could remember where I read this trick because I just codified it in MATLAB. This seems to be a common problem with an illusively simple and elegant solution.
NB: In general, this technique seems NOT to be perfect as the samples rarely represent the extremes of the original PDF. If there is a sophisticated way to induce some kurtosis to properly account for this, I'd be very interested to learn of it. |
| MATLAB release |
MATLAB 5.2 (R10)
|
| Other requirements |
I alluded to some tools in other toolboxes in the comments above, but they are NOT required to use this function. |
|
Tags for This File
|
| Everyone's Tags |
|
| Tags I've Applied |
|
| Add New Tags |
Please login to tag files.
|
| Comments and Ratings (7) |
| 14 Dec 2004 |
Craig Chippindale
|
|
|
| 30 Dec 2004 |
Hong Zhang
|
|
|
| 09 Feb 2007 |
ibrahim karauz
|
|
|
| 07 Nov 2008 |
Ameya Deoras
|
|
|
| 17 Nov 2008 |
Alex Lu
|
|
|
| 18 Nov 2008 |
Ahmed Fasih
|
|
|
| 16 Oct 2009 |
Seth
|
|
|
|
MATLAB Central Terms of Use
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for
all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content.
Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available
via MATLAB Central.
Read the complete Terms prior to use.
Contact us at files@mathworks.com