Project 1: [Hint: You can check the website at
R function代写 Write a R function to demonstration the Law of Large NumberThe function should have the following argumentsLLN(x, n , k, thprop, emprop, … )
http://www.shodor.org/interactivate/activities/AdjustableSpinner/ to learn more about Law of Large Number.
Write a R function to demonstration the Law of Large Number
The function should have the following arguments R function代写
LLN(x, n , k, thprop, emprop, … )
Where R function代写
x is the uniform random variates with size n
n: is the size of x
k: # of groups to group the n observations of generated x.
thprop: is a vector of size k that consists of k proportions (A1,A2,..,Ak). Sum of the k proportions = 100%. This is a vector of input proportion.
emprop is a vector of size k that the empirical proportions of x values in each group computed from the random data (B1,B2, … ,Bk). This is the output of proportion from n randomly generated data values.
… : is to allow you to use the pie() function in R to produce two pie charts; one for the theoretical pie chart, the other is for the empirical pie chart. (??pie to see the function usage).
The output of the function includes: R function代写
- Two pie charts; one for the theoretical pie chart, the other is for the empirical pie chart.
NOTE: If you would like to allow for additional flexibility for users to add their own labels, line type, color and title, go ahead do so. This will add extra points to your score.
- A summary table consisting the following summary data (not necessary the same words and format.
|Group||Theoretical Proportion||Empirical Ncase||Empirical Proportion||Empirical Average||Empirical Median||Empirical S.D.|
- A chi-square test to test the goodness of fit using the Empirical proportion to fit the Theoretical proportion (??chisq.test to see the function usage)
Your score depends on how complete your function can do.
You need to submit a R Markdown report consisting the following results in each r chunk (including the r code and the results for each of the following scenarios:
Two files (.Rmd and .PDF) are required using file name: Test1_Lastname_FirstnameInitial. R function代写
e.g., (i)Test1_LeeC_Prj1.Rmd , and (ii) LeeC_prj1.pdf:
- seed(11), generate n = 50, and k = 4 with theoretical proportion: equal proportion for each group
- seed(21), generate n = 50000, k = 4 with theoretical proportion: equal proportion for each group.
- seed (31), generate n =50, k =4 with theoretical proportions: (10%, 20%, 30% 40%)
- seed (41), generate n =50000, k =4 with theoretical proportions: (10%, 20%, 30% 40%)