Generate 10000 numbers using RAND with probability

  1. Given a sequence of U(0,1) random numbers, obtain and describe an algorithm that generate binary random numbers with the following point masses:
P{X = 0} = 0.3, P{X = 1} = 0.7
  • Use MATLAB (0, ) random number generator “rand” to generate 10,000 random numbers with the above distribution.
  • Compute the average value of the 10,000 numbers generated. Compare it with the theoretical mean.
  • Give the percentages of the numbers generated that are equal to -1,0, and 1, respectively. Compare them with the point masses and make a comment.

4 件のコメント

Geoff Hayes
Geoff Hayes 2022 年 3 月 30 日
@dlafont - what have you tried so far? Rather than copy and paste your homework assignment here (and like you did with https://www.mathworks.com/matlabcentral/answers/1684774-probability-calculation-for-bernoulli-trials?s_tid=srchtitle, please show us what you have tried and discuss where or why you are experiencing a problem.
dlafont
dlafont 2022 年 3 月 30 日
This is my code but I keep getting the same error. Not sure how to go about setting up rand for 10,000 digits
Torsten
Torsten 2022 年 3 月 31 日
x = rand(0,10000)
You want a vector with 0 rows and 10000 columns ?
dlafont
dlafont 2022 年 3 月 31 日
Ooops Fixed, still getting same error tho

サインインしてコメントする。

回答 (2 件)

Geoff Hayes
Geoff Hayes 2022 年 3 月 31 日

1 投票

@dlafont - from the error, I think that you have a custom script called rand.m that is is conflicting with the MATLAB rand function. I recommend you delete the /MATLAB Drive/rand.m (or better, rename this file) and try again.

1 件のコメント

dlafont
dlafont 2022 年 3 月 31 日
THANK U!!! It finally worked

サインインしてコメントする。

Ganesh shankar ram
Ganesh shankar ram 2022 年 11 月 15 日

0 投票

Generate Random Sequences of length 10000
uniformly distributed over the interval 0 and0.5

カテゴリ

ヘルプ センター および File ExchangeRandom Number Generation についてさらに検索

質問済み:

2022 年 3 月 30 日

回答済み:

2022 年 11 月 15 日

Community Treasure Hunt

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

Start Hunting!

Translated by