MATLAB Answers

Generating random data from Kernel density estimator

46 views (last 30 days)
Pg
Pg on 5 Nov 2011
Answered: Poulomi Ganguli on 5 Oct 2019
Hi,
I h've fitted my data to kernel PDF. Now to get random number from this distribution I want to generate using Metropolis-Hastings algorithm. After lot of search I found that mhsample is a built in function in MATLAB. but unable to understand how to use it for my problem. I h've problem in defining propdf and proprnd argument. If anybody can help me a bit, will be helpful.

  0 Comments

Sign in to comment.

Answers (3)

Poulomi Ganguli
Poulomi Ganguli on 5 Oct 2019
This is simple. First, estimate kernel density parameters from data vector, using fitdist:
pd = fitdist(X,'kernel');
Use this parameters to generate random samples, where 100x1 is the desired random samples:
Y = random(pd, [100,1]);
or Y = pd.random(100,1);

  0 Comments

Sign in to comment.


Abraham
Abraham on 24 Sep 2018
Hello, I would like to ask the same question because in the information provided by the matlab help it seems that the "Metropolis-Hastings" only sampling from analytical expressions.
Cheers

  0 Comments

Sign in to comment.


hamid mirzaeefard
hamid mirzaeefard on 5 Oct 2019
Hi.
This is my question too.
I need random data with kernel distribution but I don't know how can do it.

  0 Comments

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!