LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Varying probabilities from drawing from a deck of cards

What I would like to do is to take a few decks of cards, (Say decks A, B, and C) and be able to vary the probability of picking a random card out of any of the decks, for example say I want to have a 60% change of drawing any card from deck A, 30% chance from deck B, and 10% chance from deck C.

Any ideas would be very much appreciated,

~Caltech
0 Kudos
Message 1 of 4
(2,734 Views)
You simply need to map your probabilities into a linear range. For simplcity, lets assume you have only 2 cards/deck and you want a 25% chance that the card is from deck #1 and a 75% chance it's from deck 2.

Create a equally distributed random number in the range [0...8] and create the following mapping:

[0 .. 1] --> pick Card A, Deck 1
[1 .. 2] --> pick Card B, Deck 1
[2 .. 5] --> pick Card A, Deck 2
[5 .. 8] --> pick Card B, Deck 2

In general, just create a "calibration curve" that maps the ordered array of all cards into a function with a slope that represents the probability. In your case, it would have three linear segments, with different slopes for each deck. For each pick, create a random number in the range of [Ymin, Ymax] and find th
e card by inverting your function and truncating the fractional part.
Message 2 of 4
(2,734 Views)
I through this together yesterday using a method similar to what Altenbach oulined above.

See attached.

In this VI a random number between 0-1 is passed to a Threshold 1-d array. The returned fractional index is then broken into whole number index and a fraction using the Quotient remainder function by dividing by 1. The quotient is the deck number. The process is then repeated to get the card number within the deck. The mapping is controlled by the arrays passed to the Threshold 1-d arrays. THe first is non-linear with three segments. THe second is linear to select the card.

Now that I am thinking about it, the second threshold could be replaced with a multiply but I will let you try that one out.

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 3 of 4
(2,734 Views)
THanks guys, I am going to work on both you guys' ideas, it is much appreciated.


~CalTech
0 Kudos
Message 4 of 4
(2,734 Views)