Sampling with a distribution from the elements of a vector

8 ビュー (過去 30 日間)
MiauMiau
MiauMiau 2017 年 6 月 23 日
コメント済み: MiauMiau 2017 年 6 月 23 日
Hi,
Say I have an 1xm vector with any kind of numeric entries (for instance doubles or integers). As an example, I would have the vector a:
a= [0.1, 0.3, 0.5, 0.55,0.6]
Now I would like to sample from this vector with a distribution. Say I would want to use a normal distribution, then the mean would be basically the middle element of vector a. That would imply that "0.5" would be sampled most often, then "0.3" and "0.55" second most, and "0.6" and "0.1" the least number of times. How could I do that? In my concrete case, I would want to use left-skewed distribution. Any help appreciated.

回答 (1 件)

the cyclist
the cyclist 2017 年 6 月 23 日
Do you have the Statistics and Machine Learning Toolbox? If so, you could use the randsample function. Specifically, you would use the input parameter w for the weighting appropriate for the distribution you want to sample.
  1 件のコメント
MiauMiau
MiauMiau 2017 年 6 月 23 日
Ok, will have a look at it and write questions here if I will have any. Thank you!

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by