| Version: | 1.0 |
| Date: | 2026-05-05 |
| Title: | Conditional Probability Distributions in Hearts Card Game |
| Maintainer: | Barry Zeeberg <barryz2013@gmail.com> |
| Depends: | R (≥ 4.2.0) |
| Imports: | grDevices, graphics |
| 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. |
| License: | GPL-2 | GPL-3 [expanded from: GPL (≥ 2)] |
| Encoding: | UTF-8 |
| VignetteBuilder: | knitr |
| Suggests: | knitr, rmarkdown, testthat (≥ 3.0.0) |
| RoxygenNote: | 7.3.3 |
| Config/testthat/edition: | 3 |
| NeedsCompilation: | no |
| Packaged: | 2026-05-05 21:11:44 UTC; barryzeeberg |
| Author: | Barry Zeeberg [aut, cre] |
| Repository: | CRAN |
| Date/Publication: | 2026-05-11 18:50:02 UTC |
bins
Description
Randomly assign each object (card rank) to one of three bins (player hand)
Usage
bins(ranks, nbins = 3)
Arguments
ranks |
integer vector like 1:n |
nbins |
integer number of player hands = 3 |
Details
this algorithm was found in the "AI Overview" of a google search that did not provide a specific reference
Value
returns the bins (player hand) resulting from random simulations
Examples
ranks<-1:5
b<-bins(ranks)
b<-bins(1:5)
freqDistPlot
Description
plot some histograms
Usage
freqDistPlot(l2, n, dir = tempdir())
Arguments
l2 |
return value of probDist() |
n |
integer number of cards |
dir |
character string path name for png output file |
Value
returns no values but has side effect of plotting some histograms
probDist
Description
compute the histograms based on the results of the simulation studies
Usage
probDist(l, rank)
Arguments
l |
return value of rankPlayedInference() |
rank |
integer designated rank usually the highest value among rank vector |
Value
returns a list of histograms
Examples
l<-rankPlayedInference(1:5,10)
l2<-probDist(l,5)
rankPlayedInference
Description
organize the results of the simulation studies
Usage
rankPlayedInference(ranks, niter = 1000)
Arguments
ranks |
integer vector e.g. 1:n |
niter |
integer number of iterations |
Value
returns a list whose components are return values of bins()
Examples
l<-rankPlayedInference(1:5,10)
rankPlayedInferenceDriver
Description
driver to invoke rankPlayedInference(), probDist(), and freqDistPlot()
Usage
rankPlayedInferenceDriver(niter = 1000, dir)
Arguments
niter |
integer number of iterations |
dir |
param passed to freqDistPlot() |
Value
returns the return value of probDist()
Examples
dir<-tempdir()
print(sprintf("Output directory for png images is %s",dir))
l2<-rankPlayedInferenceDriver(10,dir)