| Title: | Conditional Probability Distributions in Hearts Card Game |
|---|---|
| Description: | For a given suit, if you add up the number of cards that you hold, plus the number that has been played so far, you can easily determine the number that remains in the combined hands of your three opponents. You can also determine the ("special") card of highest rank of the remaining cards for that suit. At some point, you notice that a certain opponent discards that special card. What can you infer about his holding in that suit? A series of simulation studies are reported here that allows a quantitative inference based on the conditional probability, given that the opponent has the special card. The same procedure is also used for the conditional probability, given that the opponent does not have the special card. |
| Authors: | Barry Zeeberg [aut, cre] |
| Maintainer: | Barry Zeeberg <[email protected]> |
| License: | GPL (>= 2) |
| Version: | 1.0 |
| Built: | 2026-05-11 20:41:36 UTC |
| Source: | https://github.com/cran/rankPlayedInference |
Randomly assign each object (card rank) to one of three bins (player hand)
bins(ranks, nbins = 3)bins(ranks, nbins = 3)
ranks |
integer vector like 1:n |
nbins |
integer number of player hands = 3 |
this algorithm was found in the "AI Overview" of a google search that did not provide a specific reference
returns the bins (player hand) resulting from random simulations
ranks<-1:5 b<-bins(ranks) b<-bins(1:5)ranks<-1:5 b<-bins(ranks) b<-bins(1:5)
plot some histograms
freqDistPlot(l2, n, dir = tempdir())freqDistPlot(l2, n, dir = tempdir())
l2 |
return value of probDist() |
n |
integer number of cards |
dir |
character string path name for png output file |
returns no values but has side effect of plotting some histograms
compute the histograms based on the results of the simulation studies
probDist(l, rank)probDist(l, rank)
l |
return value of rankPlayedInference() |
rank |
integer designated rank usually the highest value among rank vector |
returns a list of histograms
l<-rankPlayedInference(1:5,10) l2<-probDist(l,5)l<-rankPlayedInference(1:5,10) l2<-probDist(l,5)
organize the results of the simulation studies
rankPlayedInference(ranks, niter = 1000)rankPlayedInference(ranks, niter = 1000)
ranks |
integer vector e.g. 1:n |
niter |
integer number of iterations |
returns a list whose components are return values of bins()
l<-rankPlayedInference(1:5,10)l<-rankPlayedInference(1:5,10)
driver to invoke rankPlayedInference(), probDist(), and freqDistPlot()
rankPlayedInferenceDriver(niter = 1000, dir)rankPlayedInferenceDriver(niter = 1000, dir)
niter |
integer number of iterations |
dir |
param passed to freqDistPlot() |
returns the return value of probDist()
dir<-tempdir() print(sprintf("Output directory for png images is %s",dir)) l2<-rankPlayedInferenceDriver(10,dir)dir<-tempdir() print(sprintf("Output directory for png images is %s",dir)) l2<-rankPlayedInferenceDriver(10,dir)