How to generate random samples for a custom probability density function
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I am using 'fmincon' and 'patternsearch' of the OptimizationToolbox, R2016a. My ObjectiveFunction involves estimating the mean and variance of many arbitrary pdfs that are 1) not necessarily integrating to 1, and 2) generated in realtime by other custom functions I wrote so that the pdfs are numerically approximated rather than having any explicit analytical expression. In other words, each pdf is merely expressed as a vector 'likelihood' as a function of x, and the shape/expression of the pdf is unknown and changes as other parameters in the ObjectiveFunction vary across iterations. So I guess I should generate random samples for each pdf and estimate the stats based on these samples. However, I need the sampling to be done as fast as possible because I might need >10000 samples each time.
0 commentaires
Réponses (1)
Alan Weiss
le 29 Mar 2016
I think that the first thing you need to do is scale your likelihood so that it becomes a real pdf that integrates to 1. You can call integral for that purpose. Then I suggest that, instead of taking random samples, you numerically integrate moments of your newly-made pdf to find the mean and variance.
Alan Weiss
MATLAB mathematical toolbox documentation
1 commentaire
Voir également
Catégories
En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!