Generating random number.

1 回表示 (過去 30 日間)
Moby Philip
Moby Philip 2019 年 1 月 22 日
回答済み: Moby Philip 2019 年 1 月 24 日
Hello,
I have 2 questions to ask:
  1. I need to generate 5 gaussian distribution data having specified stabndard deviation and particular min and max value.
  2. I need to genearate 5 gaussian distribution data having minimum distance between 2 point of 2 meter and maximum distance between 2 points as 3.5 meter.
As i had used randn function but not getting data with that particular specification.
Please help regaerding that.
Thanks

採用された回答

Bjorn Gustavsson
Bjorn Gustavsson 2019 年 1 月 22 日
Well, slightly unclear question, but I'll try answering: "you need to generating some given number of random points from a Gaussian distribution with the following criteria". Since the Gaussian distribution is continuous and has infintely wide tails the only way I can see you achive this is to generate the required number of points, test if the requirements are met and then keep those otherwise draw another batch of points, repeat until stopping criteria.
Maybe there are more clever ways to achive this without introducing strange biases making the distribution of points be way off Gaussian - but that seems peculiar.
HTH
  9 件のコメント
Walter Roberson
Walter Roberson 2019 年 1 月 23 日
編集済み: Walter Roberson 2019 年 1 月 23 日
Since we are not told otherwise after repeated questions, we have to speculate that the standard deviation is 1 m, and thus that the minimal solution (if it could be randomly generated) would be [-4 -2 0 2 4] which is a span of 8 standard deviations.
Bjorn Gustavsson
Bjorn Gustavsson 2019 年 1 月 23 日
Yeah, continuing to argue this way or that way is rather pointless - the only thing we know at this point is that at least one of us are interpreting the task incorrectly.

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

その他の回答 (2 件)

Walter Roberson
Walter Roberson 2019 年 1 月 22 日
  1. Gaussian distribution is always infinite in both tails. It is a contradiction to use gaussian with min and max values.
  2. Statistics Toolbox offers makedist() and truncate() that together can create a truncated Gaussian.
  3. #2 is definitely not gaussian distribution.
  4. Your absolute distince of 2 does not mean much unless we know the standard distribution. Otherwise you are dealing with a minimum span of 8 standard deviations, like [0 2 4 6 8] 5 points no two closer than 2 together, total span is 8. 8 standard deviations is not very common; you would have to generate for a pretty long time to satisify the conditions randomly.

Moby Philip
Moby Philip 2019 年 1 月 24 日
Hello Walter and Bjorn thanks for your reply,really appreciate that. I really understood how to approach it with the help of Bjorn reply.
Thanks

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

製品


リリース

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by