Weighted sampling without replacement

前端 未结 5 1934
没有蜡笔的小新
没有蜡笔的小新 2021-01-16 14:23

I have a population p of indices and corresponding weights in vector w. I want to get k samples from this population without repla

5条回答
  •  爱一瞬间的悲伤
    2021-01-16 15:03

    This still shows up in search results, so I wanted to add the datasample function as an option. The following code will provide a weighted sample of 5 units from fromVector according the corresponding vector myWeights.

    mySample = datasample(fromVector, 5, 'Replace', false, 'Weights', myWeights)
    

提交回复
热议问题