all articles

Distributions

Part 1 - Binomial Distribution Suppose a pitcher in baseball has 50% chance of getting a strike-out. We want to use the binomial distribution to compute several things. First, we want to compute the probability distribution for striking out the next six batters. Let’s also plot these probabilities. # Assign variables and values using the number of batters and probability of a strike-out. n <- 6 ; p <- 0.5 # Compute the probability of striking out the next six batters. Read more…

Data Type Exploration with R

# Install the "UsingR" package. # install.packages("UsingR") # Load the "UsingR" library quietly by suppressing startup message. # Reference: "Package 'startupmsg'". April 23, 2016. https://cran.r-project.org/web/packages/startupmsg/startupmsg.pdf suppressPackageStartupMessages(library(UsingR)) ## Warning: package 'HistData' was built under R version 3.4.4 library(UsingR) # Use the diff function to compute differences between successive prime numbers. diff(primes) ## [1] 1 2 2 4 2 4 2 4 6 2 6 4 2 4 6 6 2 6 4 2 6 4 6 ## [24] 8 4 2 4 2 4 14 4 6 2 10 2 6 6 4 6 6 2 10 2 4 2 12 ## [47] 12 4 2 4 6 2 10 6 6 6 2 6 4 2 10 14 4 2 4 14 6 10 2 ## [70] 4 6 8 6 6 4 6 8 4 8 10 2 10 2 6 4 6 8 4 2 4 12 8 ## [93] 4 8 4 6 12 2 18 6 10 6 6 2 6 10 6 6 2 6 6 4 2 12 10 ## [116] 2 4 6 6 2 12 4 6 8 10 8 10 8 6 6 4 8 6 4 8 4 14 10 ## [139] 12 2 10 2 4 2 10 14 4 2 4 14 4 2 4 20 4 8 10 8 4 6 6 ## [162] 14 4 6 6 8 6 12 4 6 2 10 2 6 10 2 10 2 6 18 4 2 4 6 ## [185] 6 8 6 6 22 2 10 8 10 6 6 8 12 4 6 6 2 6 12 10 18 2 4 ## [208] 6 2 6 4 2 4 12 2 6 34 6 6 8 18 10 14 4 2 4 6 8 4 2 ## [231] 6 12 10 2 4 2 4 6 12 12 8 12 6 4 6 8 4 8 4 14 4 6 2 ## [254] 4 6 2 6 10 20 6 4 2 24 4 2 10 12 2 10 8 6 6 6 18 6 4 ## [277] 2 12 10 12 8 16 14 6 4 2 4 2 10 12 6 6 18 2 16 2 22 6 8 ## [300] 6 4 2 4 # Show the frequencies of the above differences. Read more…
1