Title: | Confidence Intervals Compared via Shuffling |
---|---|
Description: | Scripts and exercises that use card shuffling to teach confidence interval comparisons for different estimators. |
Authors: | Kyle Caudle |
Maintainer: | Kyle Caudle <[email protected]> |
License: | GPL-3 |
Version: | 0.1.0 |
Built: | 2025-03-12 03:12:53 UTC |
Source: | https://github.com/cran/shuffleCI |
Calculates Kendall's tau distance
ktau(list)
ktau(list)
list |
A list of numbers |
Returns the Kendall's tau distance between the input list and the sorted list 1,2,..n.
The Kendall's tau distance.
Kyle Caudle
Kendall, M. G. (1938). A new measure of rank correlation. Biometrika, 30(1/2), 81-93.
ktau(c(1,4,2,5,6,3,7))
ktau(c(1,4,2,5,6,3,7))
Determines the number of rising sequences in a list of numbers.
rseq(x)
rseq(x)
x |
List of numbers |
A rising sequence is maximal consecutively increasing subsequence.
Ex: 1,4,2,5,6,3,7 There are 3 rising sequences in this list.
(1,4,5,6,7),(2,3)
nrise - the number of rising sequences.
Kyle Caudle
Mann, B. (1995). How many times should you shuffle a deck of cards. Topics in Contemporary Probability and Its Applications, 15, 1-33.
Williams, C. O. (1912). A card reading. The Magician Monthly, 8, 67.
rseq(c(1,4,2,5,6,3,7))
rseq(c(1,4,2,5,6,3,7))
This function simulates a standard riffle shuffle of a deck of 52 playing cards.
shuffle(deck)
shuffle(deck)
deck |
A list of numbers. 1:52 would simulate a deck of cards in sequential order. |
The algorithm is based on the Gilbert-Shannon-Reeds method.
Returns a shuffled list (i.e. deck)
Kyle Caudle
Gilbert, E. (1955). Theory of shuffling. Technical memorandum, Bell Laboratories.
shuffle(1:52)
shuffle(1:52)
This function uses Kendall's tau and Rising sequences to determine how many times to shuffle a an ordinary deck of 52 playing cards.
sigtest(nreps)
sigtest(nreps)
nreps |
Number of experiment repetitions (should be at least 30/Central Limit Theorem) |
According to the Bayer & Diaconis paper, after 7 shuffles there is no benefit to shuffling any more. This simulation shows that using Kendall's tau to show this doesn't work because the variance of the Kendall's distance is too large. However, if one looks at rising sequences, the variability is smaller therefore it is possible to show the Bayer & Diaconis result.
Plots confidence intervals for each method. The print method returns the p-values from two sample t-test for the sequential interval comparisons (i.e. intervals: 3-4,4-5,5-6,6-7,7-8,8-9 and 9-10).
Kyle Caudle
Bayer, D., & Diaconis, P. (1992). Trailing the dovetail shuffle to its lair. The Annals of Applied Probability, 294-313.
sigtest(15)
sigtest(15)