Type: | Package |
Title: | Confidence Intervals Compared via Shuffling |
Version: | 0.1.0 |
Depends: | R (≥ 3.4.0),plotrix |
Author: | Kyle Caudle |
Maintainer: | Kyle Caudle <kyle.caudle@sdsmt.edu> |
Description: | Scripts and exercises that use card shuffling to teach confidence interval comparisons for different estimators. |
License: | GPL-3 |
Encoding: | UTF-8 |
LazyData: | true |
NeedsCompilation: | no |
Packaged: | 2018-03-26 21:52:18 UTC; kcaudle |
Repository: | CRAN |
Date/Publication: | 2018-04-09 14:58:39 UTC |
Kendall's tau
Description
Calculates Kendall's tau distance
Usage
ktau(list)
Arguments
list |
A list of numbers |
Details
Returns the Kendall's tau distance between the input list and the sorted list 1,2,..n.
Value
The Kendall's tau distance.
Author(s)
Kyle Caudle
References
Kendall, M. G. (1938). A new measure of rank correlation. Biometrika, 30(1/2), 81-93.
Examples
ktau(c(1,4,2,5,6,3,7))
Rising Sequences
Description
Determines the number of rising sequences in a list of numbers.
Usage
rseq(x)
Arguments
x |
List of numbers |
Details
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)
Value
nrise - the number of rising sequences.
Author(s)
Kyle Caudle
References
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.
Examples
rseq(c(1,4,2,5,6,3,7))
Riffle Shuffle
Description
This function simulates a standard riffle shuffle of a deck of 52 playing cards.
Usage
shuffle(deck)
Arguments
deck |
A list of numbers. 1:52 would simulate a deck of cards in sequential order. |
Details
The algorithm is based on the Gilbert-Shannon-Reeds method.
Value
Returns a shuffled list (i.e. deck)
Author(s)
Kyle Caudle
References
Gilbert, E. (1955). Theory of shuffling. Technical memorandum, Bell Laboratories.
Examples
shuffle(1:52)
Significance Testing
Description
This function uses Kendall's tau and Rising sequences to determine how many times to shuffle a an ordinary deck of 52 playing cards.
Usage
sigtest(nreps)
Arguments
nreps |
Number of experiment repetitions (should be at least 30/Central Limit Theorem) |
Details
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.
Value
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).
Author(s)
Kyle Caudle
References
Bayer, D., & Diaconis, P. (1992). Trailing the dovetail shuffle to its lair. The Annals of Applied Probability, 294-313.
Examples
sigtest(15)