フィルターのクリア

How can I randomly select smaller values with higher probabilities?

2 ビュー (過去 30 日間)
Stephanie Diaz
Stephanie Diaz 2018 年 3 月 1 日
編集済み: Stephanie Diaz 2018 年 3 月 1 日
I have a column vector "distances", and I want to select a value randomly from this vector such that smaller values have a higher probability of being selected. So far I am using the following, where "possible_cells" is the randomly selected value:
w=(fliplr(1:numel(distances)))/100
possible_cells=randsample((sort(distances)),1,true,w)
Basically, I flipped a second vector of the same size as "distances" to create probabilities of selection "w" (if I am understanding randsample correctly), so that the smallest value has the highest probability of being selected. To check how well this works, I randomly drew 50 values and by using a histogram, I see that the values are higher than I would expect. Does anyone have any idea on how else to do what I described above?

回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by