Oneliners here means an ungrouped R expression (ie. no semicolons).
1. Write a oneline expression which uses the plot, qnorm and sort functions to plot the normal probability plot for a batch of 50 uniform(0, 1) random numbers. Solution
2. Write a oneline expression finds the area inside the unit circle using Hit-or-Miss Monte Carlo simulation. Solution.
3. Write a oneline expression which returns TRUE or FALSE according to whether a random sample of 25 people have a birthday in common. Generate the random birthdays using sample(1:365, size=25, replace=T). Can you generalize this problem to include the effect of leap years? Solution.
4. Write a oneline expression which returns TRUE or FALSE according to whether a simulated poker hand contains a straight which is defined 5 cards in sequence without regard to suit and allowing aces to count high or low. Use this function in a simulation of 10,000 poker hands to empirically estimate the probability of this event. R Solution. Combinational solution is here.