フィルターのクリア

Drawing random numbers according to a particular scheme

3 ビュー (過去 30 日間)
Ulrik William Nash
Ulrik William Nash 2018 年 7 月 17 日
回答済み: Walter Roberson 2018 年 7 月 17 日
I have a vector, p, and each entry in p is a number between 0 and 1. Moreover, the sum of all entries in p is exactly 1. Another vector, let's call it outcomes, has the same length as p and as its name suggests, this second vector contains information about possible outcomes. Combining the vectors thus describes, for example, that the probability of encountering outcomes(1,3) is p(1,3).
My question is the following: how can I use MATLAB to generate random numbers according to p?

回答 (1 件)

Walter Roberson
Walter Roberson 2018 年 7 月 17 日
Use randsample() with a weights vector.

カテゴリ

Help Center および File ExchangeRandom Number Generation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by