Interactively Demonstrate the Sampling Distribution of a Proportion
ShinySamplingDistProp.RdLaunches a Shiny app that shows a Bernoulli “population” with a given true proportion. Clicking “Sample Once” draws a sample and shows the sample and its sample proportion; sampling in batches accumulates many sample proportions into a histogram approximating the sampling distribution of \(\hat p\).
Details
This function requires the shiny package to be installed. Set the true proportion and the sample size, then use the “Sample Once”, “Sample 5”, “Sample 100”, or “Sample 1,000” buttons to draw samples. A single sample is shown as a bar plot; multiple individual samples are shown as a scatter plot of their sample proportions. All sampled proportions accumulate into the sampling distribution histogram at the bottom. Changing the sample size resets the accumulated samples.
Value
Launches the app in non-blocking mode (via
startApp) and returns a ShinyAppHandle
immediately, so the R console remains available while the app runs
in the background. Use handle$stop() to stop the app.
Author
Greg Snow 538280@gmail.com
Examples
if(interactive()) {
h <- ShinySamplingDistProp()
# h$stop() # run this when finished with the app
}