Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

You just picked up a coin and is wondering if the coin is truly unbiased. To determine if this coin is unbiased, you decide to

You just picked up a coin and is wondering if the coin is truly unbiased. To determine if this coin is unbiased, you decide to do an experiment by flipping this coin 100 times and record how many times it returns head. Let us say this is flipping experiment No.1, and its result is the no. of heads. Then you decide to repeat this flipping experiment 999 more times (for a total of 1000 experiments, in each experiment you flip the coin 100 times).

  • Write a function called simulation_coinflip(p) returns a numpy array result with shape (1000,) where the i-th element (result[i-1]) in this array is the result of the i-th flipping test (the no. of heads in a given flip test).
  • Plot the histograms of this array using 50 bins using the resulting array of simulation_coinflip(p) for =0.2,0.5,0.7p=0.2,0.5,0.7.
  • Remark: using for loops is okay, the code for this problem can be formulated using completely vectorized routines without any for loops, and you MAY or MAY NOT find np.vectorize() (vectorize a function if there is if-else conditionals), np.mean(), np.sum(), np.apply_along_axis, np.count_nonzero(), and np.random.random() useful.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions