How do I distribute probability randomly over n values in matlab?
If I have 128 vectors.
I want to assign a random probabilty to all of them such that the sum of all of them equals to 1.
e.g.
n=4
p1=0.37
p2=0.21
p3=0
p4=0.42
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can just divide the vector by the sum of it’s elements. For example, for a vector of length 4 you can do:
Note, I am assuming you want uniformly distributed numbers, since you don’t state what distribution you want in the question.