Question: Write a R function to demonstration the Law of Large Number The function should have the following arguments LLN(x, n , k, thprop, emprop, )

Write a R function to demonstration the Law of Large Number

The function should have the following arguments LLN(x, n , k, thprop, emprop, )

Where

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 out put 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:

(a)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.

(b)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.

1

A1

N1

B1

2

A2

N2

B2

3

A3

N3

B3

k

AK

N4

BK

(c)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.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!