# How to sample from a distribution?

조회 수: 79 (최근 30일)
L'O.G. 2023년 1월 20일
댓글: Star Strider 2023년 1월 21일
How do you use randsample (or maybe something else?) to sample from a distribution? Can you define a non-standard distribution as long as you have the formula for the pdf?

댓글을 달려면 로그인하십시오.

### 채택된 답변

Star Strider 2023년 1월 20일
How do you use randsample (or maybe something else?) to sample from a distribution?
The random function can be used with known distributions.
Can you define a non-standard distribution as long as you have the formula for the pdf?
Yes. See Nonparametric and Empirical Probability Distributions for an extensive discussion. The ecdf function can be used to define an empirical distibution. (Getting random numbers from it would likely require inverting its pdf first, and that could be something of a challenge, depending on the distribution.)
.
##### 댓글 수: 4이전 댓글 2개 표시이전 댓글 2개 숨기기
L'O.G. 2023년 1월 20일
Thank you! I'll ask a similar question separately, since I think it pertains to this question. Maybe you can help me with it.
Star Strider 2023년 1월 21일
As always, my pleasure!
I will do my best!

댓글을 달려면 로그인하십시오.

### 카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

R2021b

### Community Treasure Hunt

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

Start Hunting!

Translated by