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

  Use java 5 to create a generic class drawingbox with a type

Use Java 5 to create a generic class DrawingBox with a type parameter that simulates drawing an item at random out of a box. This class could be used for simulating a random drawing.

  What basic steps are required for analyzing data using micro

Write a 200 word response that answers the following questions: What basic steps are required for analyzing data using Microsoft®Access®? How could these steps help you diagnose and troubleshoot Microsoft®Access®errors? Which of the five steps presen..

  Which of these two versions do you prefer and why

Redraw the ERD for this new situation using two entity types, and the redraw it again using one entity type. Which of these two versions do you prefer and why?

  Open systems interconnection model is inherently inefficient

The Open Systems Interconnection model is inherently inefficient. On the source host, each layer must take the work of higher layers, add some result, and pass the work to lower layers. On the destination host, each layer must process these re..

  What is the server IP address

Use Wireshark tool to capture packets when you download Lecture 1 from the COIT20229 Course Webpage. Before you undertake this task, you should have Wireshark installed in your home computer/notebook and connected to the Internet.

  State whether each reference is hit or a miss

Assume a cache has 16 1-word blocks and is initially empty. Placement is by direct mapping. Also, state whether each reference is a hit or a miss.

  Create the logic for a program that continuously prompts

The application passes the value in turn to a method that computes the sum of all the whole numbers from 1 up to and including the entered number, and to a method that computes the product of all the whole numbers up to and including the entered n..

  Write a c++ function that has an input of a char value

Write a C++ function that has an input of a char value and returns true if the character is lower case or false otherwise.

  The poisson distribution with parameter ramda?

a) the "distribution" where N is the same fixed number with probability 1?b) the Poisson distribution with parameter ramda?

  Using both printed material and online resource

Using both printed material and online resource

  Explaining index number in time series analysis

What is an index number as relates to time series analysis? In a regression of a time series that states data as a function of calendar year, what requirement of regression is violated?

  What is meant by the term digital divide

"What is meant by the term digital divide?". Write an essay (about 1300 words plus references) on the meaning of the term, who is affected, and how. In the light of recent media interest you might include traditional businesses in your discuss..

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