I want to randomly choose one element from a list but preferring elements with small distance from the center of a list. How to do it properly say with normal distribution? I am not good at statistics.
My ugly code (with unknow distribution (of triangle-like shape)):
li = Range[11];
Table[RandomChoice[
Join[Range[1, Floor[Length[#]/2]],
Range[Ceiling[Length[#]/2], 1, -1]] -> #], {i, 1000}] &@li;
ListPlot[% // Tally]
Clear[li]
Update:
Based on the answers and comments I came to the conclusion that there is no elegant solution of choosing random element from a list preferring those near the middle of the list resembling normal distribution.
Here is the code combined of comments and answers that uses normal distribution with standard deviation dev
.
li=Range[10];
le=Length[li];
dev=1;
RandomChoice[(PDF[NormalDistribution[0,dev],#]&/@Subdivide[-le/2,le/2,le-1]//N//Chop//Quiet)->li]
Clear[li,le,dev]