ANSWER:
CODE TEXT
n = 10000
trials = 6
# defining empty list to store +ve difference and -ve difference in
abs form
differences = c()
for (i in 1:trials){
# difference from expected
difference = sum(sample(c(0,1),n,replace=TRUE))/n-0.5
# appending abs(difference) in differences list
differences = append(differences,abs(difference))
print(difference)
}
# finding mean difference in differences list, to get approx +-
difference
app_difference = mean(differences)
# displaying
print(paste ("+- difference is: ",app_difference, sep = " "))
CODE IMAGE
OUTPUT IMAGE
Fraction of tails Now let's look at the fraction of tails in n trials. Fraction of...
Fraction of tails Now let's look at the fraction of tails in n trials. Fraction of tails in a small number of coin flips Heads) Suppose we flip 10 coins and compute the fraction of tails (with 1 = Tails and 0 = = 10 trials = 6 for (i in 1: trials) { print (sum(sample(c(0, 1), n, replace-TRUE)) /n) ## [1] 0.1 ## [1] 0.4 ## [1] 0.4 ## (1) 0.5 ## [1] 0.7 *# (1) 0.6 The expected...
Flipping Coins For a fair coin, the chance of getting tails is 1/2. Counting the number of tails Let's experiment with the total number of tails in n trials. Total number of tails in a small number of coin flips ם Suppose we flip 10 coins (with 1 = Tails and 0 = Heads). Here are six samples of size 10. = 10 trials = 6 for (i in 1: trials) { print (sample(c(0, 1), 1, replace=TRUE)) مه ## [1]...
Flipping Coins For a fair coin, the chance of getting tails is 1/2. Counting the number of tails Let's experiment with the total number of tails in n trials. Total number of tails in a small number of coin flips n Suppose we flip 10 coins (with 1 = Tails and 0 = Heads). Here are six samples of size 10. - 10 trials = 6 for (i in 1: trials) { print (sample(c(0, 1), n, replace=TRUE)) ## [1] 0...
2. . Write the function below per the docstring. A tuple is simply comma separated data. In the function below, the tuple returned are 2 ints. def Htcounts (flips): "Given a list, flips, of H's and T's, returns a tuple of the number of H's and the number of T's, in that order. Uses 2 sum accumulators, one for number of heads, the other of the number of tails. Traverses the list, flips, with a for loop and uses booleans...
MATLAB problem
Imagine we have three types of coins in a bag: Fair Coin (FC)
with Pr(Head) = Pr(Tail) = 0.5; Head-heavy Coin (HC) with Pr(Head)
= 0.4; and Tail-heavy Coin (TC) with Pr(Head) = 0.6. A coin is
randomly picked out of the bag. Write a MATLAB code that can
estimate the type of this coin
The result graph should look like this:
Flipping a Fair Coin for 400 Times Fiping a Coin (1 for Head and 0 for...
1. Multiple choice. Circle all the correct answers a) You flip a coin 100,000 times and record the outcome in a Xi 1 if the toss is "Heads" and 0 if its "Tails. The Law of Large Numbers says that: i. ii. It is impossible for the first n flips to all be "Heads" if n is large. With high probability, the share of coin flips that are "Heads" will approximate 50%. The sample mean of X is always 0.5...
Styles First we will learn how to evaluate binomial distribution with the help of Excel. Let's flip a coin n times and count how many tails we are going to get. If n=0, then no coin is tossed and the only option is 0 tails. Therefore P(0)=1, the mean is 0 and the standard deviation is 0. We are going to do a simple table for n=0. First we will define columns. Click on cell A1 and type X for...
Random Number Generation and Static Methods Write a program that simulates the flipping of a coin n-times to see how often it comes up heads or tails. Ask the user to type in the number of flips (n) and print out the number of times the coin lands on head and tail. Use the method ‘random()’ from the Math class to generate the random numbers, and assume that a number less than 0.5 represents a tail, and a number bigger...
use PYTHON
Assignment 4 O Let's make random IDs. Get the number of IDs from the user to make from the keyboard. Then print the IDs. O Note that the IDs should be unique. Moreover, one ID is 11-length alphabet characters including digits (i.e., A-Z, A-Z, 0-9). Template Code Example import string import random num_of_ids = int(input("Enter the number of IDs: ")) # this list contains a-z, A-Z, and digits alphabet_digit_list = string.ascii_letters + string.digits Enter the number of IDs:...