Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

I'm writing a simple computer program that has to use the following weighted table to pick a random "payment" where the relative probabilities are given by "weight".

enter image description here

How does one interpret the table above and use it to determine how much to "pay"?

EDIT: After speaking with some folks it seems this table is simple enough that I can just create a table with 41 entries where each pay amount appears ( Weight times ) and select a random number between 0 and 40 and use that to index into the table.

share|improve this question
1  
You should ask your boss. –  martin Aug 23 '12 at 22:18
1  
@kxx Thanks for the help. –  Chimera Aug 23 '12 at 22:19
1  
So, you want to pick a random "payment" where the relative probabilities are given by "weight"? If that's not what you meant, please edit the question to clarify –  Mooing Duck Aug 23 '12 at 23:04

1 Answer 1

up vote 2 down vote accepted

Assuming that the weight vector defines a finite probability distribution, you can sample payments as follows.

First pick a random integer $x \in [0, 41]$. Then the payment is as follows:

$0 \le x \le 20$ : $200 + 50 \lfloor x/3 \rfloor$

$21 \le x \le 38$ : $550 + 50 \lfloor (x-21)/2 \rfloor$

$39 \le x \le 41$ : $1000 + 500 (x - 39)$

share|improve this answer
    
How do you get 41? Along with this table came the statement, "Can be changed to a table of 41 objects of equal probability. The 200 would appear on it 3 times." –  Chimera Aug 23 '12 at 22:40
    
I ask because I'm just trying to understand how to interpret the table so the next time I get something like this I can figure it out myself. Thanks.. –  Chimera Aug 23 '12 at 22:41
    
You probably got the table from an excel sheet, and excel probably has a function that samples the payment automatically given these two columns. Maybe you should ask someone who knows something about excel. –  martin Aug 23 '12 at 22:51
    
Thanks for all of the help. However, I'm not interested in learning about Excel, I'm trying to understand how to use such a probability table in a program. I'm looking to understand the math behind it. –  Chimera Aug 23 '12 at 23:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.