I have the following RStudio code which works
match_prob <- function(x) choose(2*N-x,N)*2 ̂ {-(2*N-x)}
It corresponds to P(E) = (2N-k,N)(1/2)^(2N-k)
I however want to use a slightly different function. Is it possible to input for the following:
P(E) = 2(2N-k,N)(1/2)^(2N-k)
I tried entering it in by changing the function slightly to:
match_prob <- function(x) choose(2*(2*N-x,N))*2 ̂ {-(2*N-x)}
and immediately got the error, "Error: unexpected ',' in "match_prob"...
The change was a factor of 2 since the container which are considered are symmetric and makes no difference overall.
(I know not much context but I left that off as it wasn't really relevant to the RStudio specific question :) If needed I can elaborate further on it though)
I'm very new to RStudio so still fumbling my way through it.
Thanks,
1 ) P(E) = (2N-k,N)(1/2)^(2N-k)
N = 10
match_prob = function(x) {
(choose(2*N - x , N)) * (2 ^ -(2*N - x))
}
match_prob(5)
output -
> match_prob(5)
[1] 0.09164429
2 ) P(E) = (2 *(2N-k,N)) * (1/2)^(2N-k)
match_prob = function(x) {
(2*(choose(2*N - x , N))) * (2 ^ -(2*N - x))
}
match_prob(5)
output =
> match_prob(5)
[1] 0.1832886
plz like ;) if any further issues kindly ask in comment section
Get Answers For Free
Most questions answered within 1 hours.