How to randomly sample points within some range using a distribution fit obtained from distribution fitter app?

3 ビュー (過去 30 日間)
I am used distribution fitter app to fit a probability distribution on my data, and I am able to save distribution object to workspace.
Now I want to use newly fitted distribution to generate random numbers within a desired range. 
Please help me in achieving this workflow.

採用された回答

MathWorks Support Team
MathWorks Support Team 2025 年 1 月 25 日
編集済み: MathWorks Support Team 2025 年 1 月 31 日
As a workaround, please try the following steps:
  • Save the probability distribution object from the "distributionFitter" app to the workspace. It usually saves a variable named "pd".
  • Use the "truncate" function to create a new distribution object within the desired limits.
  • Use the "random" function to generate numbers randomly using the distribution object.
>> pd_truncated = truncate(pd,45,60); >> number = random(pd_truncated)
For more details, you can refer to the documentation about the "truncate" function by executing the commands in the MATLAB R2020a command window:
>> web(fullfile(docroot, 'stats/prob.normaldistribution.truncate.html'))
For more details, you can refer to the documentation about the "random" function by executing the commands in the MATLAB R2020a command window: 
>> web(fullfile(docroot, 'stats/prob.normaldistribution.random.html'))
Please follow the link below to search for the required information regarding the current release:

その他の回答 (0 件)

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by