Forming a CDF by adding different types of PDF and generating random number

10 visualizzazioni (ultimi 30 giorni)
Hello,
I have read certain threads on generating random numbers and developing distributions functions in MATLAB. I could not get the answer to my doubt and also guess I am not aware of all the functions and capabilitites of MATLAB still.
I am trying the develop a CDF from multiple PDFs (of different variables). I am able to do that. But the next part- generating random number from this custom CDF is very tricky and creating nuisance. Can you please tell me- if I can know the type of distribution of this custom CDF (without using Distribution Fitter toolbox,if possible- as this is in the middle of the program, running multiple times)??
I want to fit this CDF to suitable PDF and then generate the random number from that PDF. Please guide.
(Please let me know if I am missing on something.)
Thank you in advance for your time.

Risposta accettata

Jeff Miller
Jeff Miller il 4 Set 2021
It seems like there are several different questions here.
  1. If you want to generate random numbers from a custom CDF, one simple procedure is to generate uniform(0,1) random numbers with u=rand, and then find the X value whose CDF equals u within your custom CDF.
  2. Can you know the type of distribution of your custom CDF? Well, not necessarily, no, because your custom CDF does not have to match that of any known distribution. You can try different known distributions and see how well their CDFs match yours, but there might not be any with a good match.
  3. Fitting the CDF to a suitable PDF...I'm not sure exactly what you have in mind here--maybe this is the same as #2. But if you have the custom CDF then you can simply compute the corresponding custom PDF by numerical differentiation. But that won't help you generate random numbers--for that purpose, the CDF format is more convenient (see #1).
Hope that helps,
  14 Commenti
Rohit Mangalekar
Rohit Mangalekar il 14 Set 2021
Modificato: Rohit Mangalekar il 14 Set 2021
Hello Jeff, Thank you very much once again. This is absolutely correct reason for the error. My "y" (the array I am using in that loop, a CDF) was not approaching 1. That was the reason the values in "u" like 0.96 were not matching with any of the values in "y".
I am very thankful for your time and your such a nice explainations. Hope to explore such intricacies of MATLAB and do better programming.

Accedi per commentare.

Più risposte (0)

Prodotti


Release

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by