R programming language resources › Forums › Data manipulation › Combinatorics problem: create dataframes reflecting Probability distribution
Tagged: combinatronics, creation of datasets, probability
 This topic has 0 replies, 1 voice, and was last updated 5 years, 6 months ago by kwijyboo.

AuthorPosts

January 28, 2015 at 11:46 am #1101kwijybooMember
Hello I am a total beginner with no experience in R so please be patient and excuse if I use terms not 100% appropriately.
here is the problem, I think is quite challenging, I have to write a program that estimates the composition of a set given that we assign ranges of values to some variables. Let’s take a common Card Deck to make an examples:
52 elements (cards) of 13 ranks (A=stronger…2=weaker) and 4 types called “suits” (hearts=h, diamond=d, clubs=c, spades=s).
let’s set variable
a= Kh,Kd (meaning that we subtracted K of hearts and K of diamonds from the Deck)
Now Deck = 50 with 2 types of elements (clubs, spades) unchanged and 2 type (hearts, diamonds) loose 2 elements of the same high rank (K=2nd place)
therefore we can make an exact prediction on Probability of variable b being equal to any combos
variable b has 1225 possible values equivalent to 1225 “types” of combinations between remaining elements in the Deck (50*49/2), types are:
1. 2 elements of the same type (suit): ie AhJh, KsQs…
2. 2 elements of the same rank (pairs): ie AhAd…2c2s
3. 3 elements of different type and rank (unpaired, offsuites): ie AhKs…9s3h
Now in this example Probability of variable b being equal to any combinations of KK is 1/1225 because we know 100% that Deck contains only 2 Kings so only 1 combos is possible (we are interest in combinations not permutations, order doesn’t count, KsKc=KcKs, the only thing that matters is the “presence” of 2 given elements in a variable, not their order)But what if variable a is a range of combinations? Say:
a = (KK, AK) # 6 combos of KK and 16 combos of AK
Now we cannot say exactly which elements the Deck is missing, but we can only say that:
27.2% the times Deck will miss 2 Kings (a = 6 combos of Kings / (6+16) possible combos)
72.8% the times Deck will miss 1 Ace and 1 King (16/(6+16))Now Probability of b=KK is:
27.2% = 1/1225
+
72.8% = 3/1225 (72.8% variable a subtracts only one King from deck, therefore 3 combos of KK are possible)
=
0.002 or 0.02%I am looking for a script that, given a certain number of variable representing ranges of combinations (such as a and b in the example) will determine:
1. Probability of each combination of 2 cards being in range x
2. probability of each combination of 3 cards being in range fthanks for your help

AuthorPosts
 You must be logged in to reply to this topic.