0
$\begingroup$

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.

  • 1
    You should ask your boss.2012-08-23
  • 1
    @kxx Thanks for the help.2012-08-23
  • 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 clarify2012-08-23

1 Answers 1

2

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)$

  • 0
    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."2012-08-23
  • 0
    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..2012-08-23
  • 0
    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.2012-08-23
  • 0
    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.2012-08-23