Gamma Random Number with Shape Parameter from Matrix

2 次查看(过去 30 天)
For example, my shape parameter value in 1x5 matrix = [1.1 1.2 1.3 1.4 1.5] and my scale parameter value is 2. How to generate gamma random number from those value at once so I can get the results in 1x5 matrix? Actually I want to generate from matrices 1x100 so it will be quite difficult if I have to generate them one-by-one manually.
Thank you for your kind help!
Regards,
Debby

回答(1 个)

Walter Roberson
Walter Roberson 2020-6-9
gamrnd(2, [1.1 1.2 1.3 1.4 1.5])
  1 个评论
Debby Chairubby Lubis
Appreciate your kind answer!
However, I think it would be gamrnd([1.1 1.2 1.3 1.4 1.5], 2) since the format of gamrnd(A,B) which is A is the shape parameter. So, if my shape parameter is in 1x100 matrix, the code is as below:
shape_parameter = [2.14 2.30 2.46 2.64 2.83 3.03 3.25 3.48 3.73 4.00 4.29 4.59 4.92 5.28 5.66 6.06 6.50 6.96 7.46 8.00 8.57 9.19 9.85 10.56 11.31 12.13 13.00 13.93 14.93 16.00 17.15 18.38 19.70 21.11 22.63 24.25 25.99 27.86 29.86 32.00 34.30 36.76 39.40 42.22 45.25 48.50 51.98 55.72 59.71 64.00 68.59 73.52 78.79 84.45 90.51 97.01 103.97 111.43 119.43 128.00 137.19 147.03 157.59 168.90 181.02 194.01 207.94 222.86 238.86 256.00 274.37 294.07 315.17 337.79 362.04 388.02 415.87 445.72 477.71 512.00 548.75 588.13 630.35 675.59 724.08 776.05 831.75 891.44 955.43 1024.00 1097.50 1176.27 1260.69 1351.18 1448.15 1552.09 1663.49 1782.89 1910.85 2048.00]
scale_parameter = 0.3
x = gamrnd([2.14 2.30 2.46 2.64 2.83 3.03 3.25 3.48 3.73 4.00 4.29 4.59 4.92 5.28 5.66 6.06 6.50 6.96 7.46 8.00 8.57 9.19 9.85 10.56 11.31 12.13 13.00 13.93 14.93 16.00 17.15 18.38 19.70 21.11 22.63 24.25 25.99 27.86 29.86 32.00 34.30 36.76 39.40 42.22 45.25 48.50 51.98 55.72 59.71 64.00 68.59 73.52 78.79 84.45 90.51 97.01 103.97 111.43 119.43 128.00 137.19 147.03 157.59 168.90 181.02 194.01 207.94 222.86 238.86 256.00 274.37 294.07 315.17 337.79 362.04 388.02 415.87 445.72 477.71 512.00 548.75 588.13 630.35 675.59 724.08 776.05 831.75 891.44 955.43 1024.00 1097.50 1176.27 1260.69 1351.18 1448.15 1552.09 1663.49 1782.89 1910.85 2048.00], 0.3)
Is there no easier/quicker code since I have 1x100 matrix?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Gamma Functions 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by