Create a function that takes in x

Assignment Help Basic Computer Science
Reference no: EM13765589

Problem 1

The goal of this simulation problem is to examine how accurate the normal approximation to binomial is without the continuity correction.

Create a function that takes in x (the number of successes we are interested in), n the total sample size, p the proportion of successes, and Which Way which will take on characters "<", ">","<=",">=". This function should perform the following steps:

Step i. Find the exact probability we are interested in using the built in R function pbinom (see handout for details). Notice you should have an if else chain which calculates the probability based on Which Way. Call this value True Prob.

Step ii. Inside the if else chain, you should also calculate the normal approximation to binomial for the value of x. Do not implement the continuity correction. Call this value Approx Prob.

Step iii. Your function should output the difference between the exact probability and the approximate probability. Then, use your function to calculate the absolute value of the difference between the exact and approximate probability for the following probabilities and parameters:

(a) P(X < 7) for n = 15, p = 0.40
(b) P(X ≥ 5) for n = 30, p = 0.20
(c) P(X ≤ 10) for n = 50, p = 0.25
(d) P(X > 50) for n = 200, p = 0.10

Problem 2

The goal of this simulation problem is to examine how accurate the normal approximation to binomial is with the continuity correction.
Create a function that takes in x (the number of successes we are interested in), n the total sample size, p the proportion of successes, and Which Way which will take on characters "<", ">","<=",">=".
Notice that you should be able to modify your previous function (give it a new name though), and this time implement the continuity correction. Then, use your function to calculate the absolute value of the difference between the exact and approximate probability for the following probabilities and parameters:
(a) P(X < 7) for n = 15, p = 0.40
(b) P(X ≥ 5) for n = 30, p = 0.20
(c) P(X ≤ 10) for n = 50, p = 0.25
(d) P(X > 50) for n = 200, p = 0.10

Problem 3

This problem will use your functions from Problem 1 and Problem 2 to see how the approximations perform when n increases. Your function should take in a vector of sample sizes all.n, the probability of success p, and Which Way which will take on characters "<", ">","<=",">=".

Create a function that calculates the following binomial probability:
P(X ≤ (n/2)) and returns a matrix of all. n rows, and two columns; the first column being the difference between the actual probability and the normal approximation to binomial without the continuity correction for all values in all. n, and the second being the difference between the actual probability and the normal approximation to binomial with the continuity correction for all values in all. n.

Hint: sapply will automatically create a matrix if you return two values in your sapply loop. If it is the reverse of what you want, you can use X = t(X) to flip the matrix.

Then, use your function to do the following:

(a) For all.n = seq(10,400,2), p = 0.50, and the appropriate value of WhichWay, use your function to get back a large matrix of the differences. Do not print out this matrix!. Find the mean of each column and report the two means.

(b) Then, create a histogram of the differences between the actual and approximate probabilities for each method (with and without continuity). Report these two histograms (make sure you label them!).

(c) Also create two separate line plots where the values of all.n are on the x-axis, and the difference between the actual and approximate probabilities are on the y-axis. Report the two line graphs (make sure you label them!) Notice the default axis limits.

(d) Do you think the continuity correction is worth implementing? I.e, if you were approximating a binomial probability with a normal distribution, would you use the continuity correction? You can use parts (a), (b) and (c) to support your answer.

Reference no: EM13765589

Questions Cloud

Describing your personal criminological theory : Write a 700- to 1,050-word paper describing your personal criminological theory. Address the following in your paper: How would you explain the occurrence of crime and why people commit crime
Estimate the quantity of connectivity routers-switches : Your organization opened seven new branch offices in five states. Each branch office has five floors. All the branch offices use the same Internet domain name. The organization has approximately 25 servers and anticipates that an additional 30 ser..
Product using the production method : Assuming Sunny Day accounts for the by product using the production method, what is the inventoriable cost for each product and Sunny Day's gross margin?
Explain why many children growing up in poor families : explain why many children growing up in poor families succeed in school and in life citing your Learning Resources for this week to validate your thinking and ideas.
Create a function that takes in x : Create a function that takes in x (the number of successes we are interested in), n the total sample size, p the proportion of successes, and Which Way which will take on characters " "," =". This function should perform the following steps:
Identification and analysis and effective decision-making : Considering the context as described above, how do organizations - in terms of culture, structure, and traditional ways of doing things (processes), impact both risk identification and analysis (RIA) and effective decision-making
Managing health care quality issue : Write clearly and concisely about health care management using proper writing mechanics.
Identify the philosophical basis for each theory : Write a 1,050- to 1,750-word paper in which you evaluate your selected criminological theory. Identify the philosophical basis for each theory
Define the accounting equation : Define the accounting equation. Define, explain, and example the following: Asset, Liability, Equity, Revenue, and Expense.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Identifies the cost of computer

identifies the cost of computer components to configure a computer system (including all peripheral devices where needed) for use in one of the following four situations:

  Input devices

Compare how the gestures data is generated and represented for interpretation in each of the following input devices. In your comparison, consider the data formats (radio waves, electrical signal, sound, etc.), device drivers, operating systems suppo..

  Cores on computer systems

Assignment : Cores on Computer Systems:  Differentiate between multiprocessor systems and many-core systems in terms of power efficiency, cost benefit analysis, instructions processing efficiency, and packaging form factors.

  Prepare an annual budget in an excel spreadsheet

Prepare working solutions in Excel that will manage the annual budget

  Write a research paper in relation to a software design

Research paper in relation to a Software Design related topic

  Describe the forest, domain, ou, and trust configuration

Describe the forest, domain, OU, and trust configuration for Bluesky. Include a chart or diagram of the current configuration. Currently Bluesky has a single domain and default OU structure.

  Construct a truth table for the boolean expression

Construct a truth table for the Boolean expressions ABC + A'B'C' ABC + AB'C' + A'B'C' A(BC' + B'C)

  Evaluate the cost of materials

Evaluate the cost of materials

  The marie simulator

Depending on how comfortable you are with using the MARIE simulator after reading

  What is the main advantage of using master pages

What is the main advantage of using master pages. Explain the purpose and advantage of using styles.

  Describe the three fundamental models of distributed systems

Explain the two approaches to packet delivery by the network layer in Distributed Systems. Describe the three fundamental models of Distributed Systems

  Distinguish between caching and buffering

Distinguish between caching and buffering The failure model defines the ways in which failure may occur in order to provide an understanding of the effects of failure. Give one type of failure with a brief description of the failure

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd