新手最近刚在学习使用Rstudio,有些问题问下坛里的大大。1. Using R, write a program to calculate all the prime numbers less than 100. A prime number is a positiveinteger divisible (without remainder) only by 1 and itself. Create the program by testing each numberfrom 1 to 100 against all integers less than it using %%. Your function should return a vector of all theprimes < 100.
2. Using R, create a histogram of the result from 1 using ggplot. Be sure to nicely label your axes andtitle the graph.
3. You flip a coin five times.
a. What’s the chance of getting three or more heads in a row?
b. What’s the chance of getting three or more heads in a row conditional on knowing the first flip was aheads?
4. NASA has declared that the Earth is likely to be hit by an asteroid this year based on an astronomicalobservation it has made. These things are hard to judge for certain, but it is known that the test NASAused is pretty good – it has an accuracy (sensitivity) of 99% and a false positive rate of only 1%. It isfurther known that the general probability of an asteroid hitting earth in any given year is 1 in 100,000.What is the probability we will actually be hit by an asteroid this year given NASA’s test?
5. The average number of snow days in Beijing in a winter month is 1. Assuming these events follow apoisson distribution, what is the probability of getting 5 or more snow days in a month?
6. You want to know how many hours of sleep the average college student gets. You start out witha preliminary survey of 10 people, and get the following data (in hours): 7,6,5,8,6,6,4,5,8,7. Youhypothesize that despite what the doctors say, the average college student does not get 7 hours of sleepa night. What does your survey say? State your null hypothesis, research hypothesis (two tailed), andcalculate your threshold value, test statistic, and p value. Do you reject the null or not?
7. Despite the disappointing results in 6, you are confident in your hypothesis. Assuming your samplestandard deviation and mean do not change and you want to survey as few people as possible, howmany additional people would you have to survey to reject the null at the 0.05 level?
8. You survey the same 10 people during finals period, and get the following hours: 5,4,5,7,5,4,5,4,6,5 .Do people get significantly less sleep during finals?
9. You are a very bad gardener, and hypothesize that feeding houseplants vodka might help them relaxand grow better. You perform an experiment to test your hypothesis, giving 15 houseplants waterspiked with vodka, and 15 houseplants water alone. These are your results:condition live die
treatment 4 11
control 8 7
This looks pretty bad for the treatment, but being as good at statistics as you are bad at gardening,1you test it using the chi-square test. What are your results?
10. Perhaps you got things backwards, and plants need more stimulation to thrive. So you adjust yourexperiment into three treatment groups: water, vodka, and coffee.
These are your results: condition mean-days-alive sd n
water 50 10 20
vodka 45 7 10
coffee 55 4 10
The overall mean is 50 days (as we said, you’re a bad gardener). Use an F test to determine ifthere is any significant difference among these three groups.