Problem with index function in symsum function

2 ビュー (過去 30 日間)
Ege Artan
Ege Artan 2022 年 1 月 27 日
回答済み: Rishabh Singh 2022 年 2 月 3 日
I was trying to code a random number generator that could generate random numbers on the interval [a,b] and thinking that having more random iterations would make this random number more random. And by summing up al these numbers and dividing them to the number n, I am aiming to make a better number generator (probably this is problematic in terms of probability to think like this way). However when using symsum function with the index function in my case x(k,1) the following error occurs:
I tried troubleshooting by changing places of function, index and the interval inside symsum function or adding paranthesis and removing them, however as expected the problem couldn't be solved. What am I doing wrong here? Thanks for your help.
  4 件のコメント
Torsten
Torsten 2022 年 1 月 27 日
編集済み: Torsten 2022 年 1 月 27 日
Since no symbolic variables are involved, why do you use symsum ?
You must use "sum" instead.
Ege Artan
Ege Artan 2022 年 1 月 27 日
Thanks seems like I still have lots to learn!

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

回答 (1 件)

Rishabh Singh
Rishabh Singh 2022 年 2 月 3 日
Hi,
I am unable to understand the idea of better number generator. But in terms of probability generating random numbers and taking their average will change the probability distribution, which for "rand" function in "Uniform Distribution". When taking average you will output random number near to (a+b)/2 with much greater probability compared to other random numbers. You can confirm this by increasing the value of "c" and obverving the value of "x",
a = 3;
b = 16;
c = 78;
x = a + (b-a)*rand(c,1);
x = sum(x)/c;
Hope this helps.

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by