有沒有辦法可以得到滿足用戶確定的分佈函數的隨機數生成。在MATLAB中,我發現只有均勻和正態分佈函數的隨機數發生器。隨機數與用戶定義分佈函數(MATLAB)
2
A
回答
2
Statistics Toolbox有大量具有預定義分佈的隨機數生成器。希望那些你需要包含在列表中:
Random Number Generators. betarnd - Beta random numbers. binornd - Binomial random numbers. chi2rnd - Chi square random numbers. evrnd - Extreme value random numbers. exprnd - Exponential random numbers. frnd - F random numbers. gamrnd - Gamma random numbers. geornd - Geometric random numbers. gevrnd - Generalized extreme value random numbers. gprnd - Generalized Pareto inverse random numbers. hygernd - Hypergeometric random numbers. iwishrnd - Inverse Wishart random matrix. johnsrnd - Random numbers from the Johnson system of distributions. lognrnd - Lognormal random numbers. mhsample - Metropolis-Hastings algorithm. mnrnd - Multinomial random vectors. mvnrnd - Multivariate normal random vectors. mvtrnd - Multivariate t random vectors. nbinrnd - Negative binomial random numbers. ncfrnd - Noncentral F random numbers. nctrnd - Noncentral t random numbers. ncx2rnd - Noncentral Chi-square random numbers. normrnd - Normal (Gaussian) random numbers. pearsrnd - Random numbers from the Pearson system of distributions. poissrnd - Poisson random numbers. randg - Gamma random numbers (unit scale). random - Random numbers from specified distribution. randsample - Random sample from finite population. raylrnd - Rayleigh random numbers. slicesample - Slice sampling method. trnd - T random numbers. unidrnd - Discrete uniform random numbers. unifrnd - Uniform random numbers. wblrnd - Weibull random numbers. wishrnd - Wishart random matrix.
你也可以使用random
,基本要求,這取決於分佈的名稱的上述功能之一:
RANDOM Generate random arrays from a specified distribution. R = RANDOM(NAME,A) returns an array of random numbers chosen from the one-parameter probability distribution specified by NAME with parameter values A. [...] NAME can be: 'beta' or 'Beta', 'bino' or 'Binomial', 'chi2' or 'Chisquare', 'exp' or 'Exponential', 'ev' or 'Extreme Value', 'f' or 'F', 'gam' or 'Gamma', 'gev' or 'Generalized Extreme Value', 'gp' or 'Generalized Pareto', 'geo' or 'Geometric', 'hyge' or 'Hypergeometric', 'logn' or 'Lognormal', 'nbin' or 'Negative Binomial', 'ncf' or 'Noncentral F', 'nct' or 'Noncentral t', 'ncx2' or 'Noncentral Chi-square', 'norm' or 'Normal', 'poiss' or 'Poisson', 'rayl' or 'Rayleigh', 't' or 'T', 'unif' or 'Uniform', 'unid' or 'Discrete Uniform', 'wbl' or 'Weibull'.
2
您可以隨時使用randsample
加權採樣。假設你想用概率p
(其中p
是長度n
的非負向量),那麼
randsample(n, k, true, p);
+1
+1但是,這隻適用於_discrete_分發具有可能值的數目_finite_ –
相關問題
- 1. Matlab中的隨機函數分佈
- 2. SQL隨機數用戶定義函數
- 3. 如何創建一個自定義的隨機分佈函數?
- 4. Java:根據用戶定義的函數生成隨機數
- 5. R:分佈函數返回「隨機」值
- 6. 以對數分佈和自定義斜率生成隨機數
- 7. Matlab - 用戶定義的函數作爲函數的參數
- 8. 隨機數字分佈
- 9. 隨機數分佈C++ 11
- 10. glmer的用戶定義的隨機截距分佈
- 11. 在matlab中使用高斯和均勻分佈的隨機數
- 12. 在Matlab中使用分佈的隨機數
- 13. 自定義jQuery函數隨機undefined
- 14. 在matlab中定義自己的概率分佈函數
- 15. 產生隨機數與給定的分佈
- 16. 生成指數分佈的隨機數
- 17. 從指數分佈生成隨機數
- 18. 在Matlab中的正態分佈的隨機數
- 19. MATLAB回調函數:未定義函數?
- 20. 定義一組隨機數
- 21. DotNetOpenAuth自定義隨機數
- 22. 根據概率分佈函數生成隨機數
- 23. 隨機數生成使用srand()函數定義一個變量
- 24. 定義Python函數與用戶輸入
- 25. Matlab`localfunctions`函數未定義
- 26. matlab函數變量定義
- 27. 隨機數函數
- 28. 使用Matlab生成奇數隨機數
- 29. 隨機函數
- 30. 隨機函數
你會怎樣想指定該「用戶確定的分佈函數」來樣範圍內
1:n
k
號碼?也離散或連續? – Dan你有沒有讀過:http://stackoverflow.com/questions/13914066/generate-random-number-with-given-probability-matlab – Dan
丹,你最近的評論是有用的 – freude