Question

Complete the following method. /** * This method calculates the probability of tossing a * coin...

Complete the following method.

    /**
     * This method calculates the probability of tossing a 
     * coin n times and and getting n heads.
     *
     * The probability of getting a single head is 0.5.  The
     * probability of getting two heads is 0.5*0.5.
     * The probability of n heads is 0.5*0.5*...*0.5 (where there are
     * n terms in the product).
     *
     * @param n      The number of tosses
     * @return       The probability of n heads in n tosses
     */
    public static double probabilityOfHeads(int n)
    {





    }
    
0 0
Add a comment Improve this question Transcribed image text
Answer #1
public static double probabilityOfHeads(int n) {
  double d = 1;
  for(int i = 0;i<n;i++){
    d = d * 0.5;
  }
  return d;
}
Add a comment
Know the answer?
Add Answer to:
Complete the following method. /** * This method calculates the probability of tossing a * coin...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • A fair coin is tossed 6 times. A) What is the probability of tossing a tail...

    A fair coin is tossed 6 times. A) What is the probability of tossing a tail on the 6th toss given the preceding 5 tosses were heads? B) What is the probability of getting either 6 heads or 6 tails?

  • 8.46 Sample size for tossing a coin. Refer to Exercise 8.39 where we analyzed the 10,000...

    8.46 Sample size for tossing a coin. Refer to Exercise 8.39 where we analyzed the 10,000 coin tosses made by John Kerrich. Suppose that you want to design as a study that would test the hypothesis that a coin is fair if versus the alternative that the probability of a head is 0.05. what sample 0.51. Using a two-sided test with a = size would be needed to have 0.80 power to detect this alternative? us 8.39 Tossing a coin...

  • Problem 10) A fair coin is tossed 20 times. A fair coin means that the probability...

    Problem 10) A fair coin is tossed 20 times. A fair coin means that the probability of getting a head is the same as the probability of getting a tril. Let X be the number of coins of getting head. Note that there are only two possible outcomes: getting head or tail after tossing the coin X follows a binomial distribution with n =20, p=0.5. Answer the following questions (Question) Find PX-17).

  • An experiment consists of tossing an unfair coin (49% chance of landing on heads) a specified...

    An experiment consists of tossing an unfair coin (49% chance of landing on heads) a specified number of times and recording the outcomes. (a) What is the probability that the first head will occur on the second trial? (Use 4 decimal places.) Does this probability change if we toss the coin three times? What if we toss the coin four times? The probability changes if we toss the coin four times, but does not change if we toss the coin...

  • Example : In tossing a coin once , Find the probability of events ? 1) The...

    Example : In tossing a coin once , Find the probability of events ? 1) The event A is the first tossing is heads 2) The event B is the first tossing is tails 3) The event c is the getting is one at least heads 4) The event c is the getting is one at most tails -------------------------------- Example : In tossing a coin once , Find the probability of events ? 1) The event A is the first...

  • Problem 4, 5 p. ] (in prepation to the binomial model) Consider tossing a coin n...

    Problem 4, 5 p. ] (in prepation to the binomial model) Consider tossing a coin n times where n 1 is fixed. Assume that the probability of occurring of "heads" is p(0< p1), and the probability of occurring of "tails" is q1-p and the outcomes of single tosses are independent of each other. Describe the sample space Ω of that experiment (all possible outcomes) and how the corresponding probability function P on Ω looks like. In other words, prescribe P...

  • QUESTION 8 Problem 8) A fair coin is tossed 20 times. A fair coin means that...

    QUESTION 8 Problem 8) A fair coin is tossed 20 times. A fair coin means that the probability of getting a head is the same as the probability of getting a tail. Let X be the number of coins of getting head. Note that there are only two possible outcomes: getting head or tail after tossing the coin. X follows a binomial distribution with n=20, p=0.5. Answer the following questions. (Question) Find the expected value of X, E(X). QUESTION 9...

  • An experiment consists of tossing an unfair coin (53% chance of landing on heads) a specified...

    An experiment consists of tossing an unfair coin (53% chance of landing on heads) a specified number of times and recording the outcomes. (a) What is the probability that the first head will occur on the second trial? (Use 4 decimal places.) Does this probability change if we toss the coin three times? What if we toss the coin four times? The probability changes if we toss the coin three times, but does not change if we toss the coin...

  • The Coin Tossing simulation Coin.java The Coin class must be the enum class, defining the instances...

    The Coin Tossing simulation Coin.java The Coin class must be the enum class, defining the instances HEADS and TAILS. CoinTossing.java The CoinTossing class should be a simple class (with a main method) that uses the values provided by a Coin class, and performs a simulation of the tossing of a coin. There must be a separate (possibly static) flip method that takes no arguments and returns a value of the Coin class. The result returned from the flip method is...

  • QUESTION 9 4 Problem 9) A fair coin is tossed 20 times. A fair coin means...

    QUESTION 9 4 Problem 9) A fair coin is tossed 20 times. A fair coin means that the probability of getting a head is the same as the probability of getting a tail. Let X be the number of coins of getting head. Note that there are only two possible outcomes: getting head or tail after tossing the coin X follows a binomial distribution with n -20.p=0.5. Answer the following questions. (Question) Find the variance of X, Var(X).

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT