# The variables 'green', 'black', and 'red' contain the number of pockets for each color green <- 2 black <- 18 red <- 18 # Assign a variable `p_green` as the probability of the ball landing in a green pocket p_green <- green / (green+black+red) # Assign a variable `p_not_green` as the probability of the ball not landing in a green pocket p_not_green <- 1-p_green # Compute the standard error of the random variable abs(17 - -1) * sqrt(p_green(p_not_green)) #> Error in p_green(p_not_green): could not find function "p_green"
What I am trying to do: The standard error of a random variable X tells us the difference between a random variable and its expected value. You calculated a random variable X in exercise 2 and the expected value of that random variable in exercise 3.
The output I desire: Now, compute the standard error of that random variable, which represents a single outcome after one spin of the roulette wheel.
The output I am getting : Error: could not find function "p_green". I understand the error, just not sure how to correct it. can someone hint me the correct syntax ? thanks
In the way you've written this, you are saying "put the object
p_not_green into a function named
p_green". That is, when you follow a name with parentheses, R usually assumes you are trying to call a function. That's why you get the error "
Error in p_green(p_not_green): could not find function "p_green""
I think you probably want to be applying some operator to these two objects, e.g.
(p_green + p_not_green).
Also just to note our homework policy: FAQ: Homework Policy
But I think asking for hints as to how best to resolve issues with your approach to solving a homework problem, as Paul does, is usually cool.
This topic has been closed.
If you have a query related to it or one of the replies, start a new topic and refer back with a link. #5