Question

I have the following RStudio code which works match_prob <- function(x) choose(2*N-x,N)*2 ̂ {-(2*N-x)} It corresponds...

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,

Homework Answers

Answer #1

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

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions