Question

Problem 9) Given a biased coin analogy, if a bit vector is 30% full, what are the odds that 5 bits randomly chosen all fall w

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Manual Calculation:

Probability of single bit fall in 30% area is 30/100

Probability of all 5 bit fall in 30% area is (30/100)^5=0.00243

By computer simulation the output is is 0.002483

Programming:

Since there is nothing mentioned in the question, I am using C++ programming language for code development.

#include<iostream>                    //Header file inclusion
#include<stdlib.h>                      //Header file inclusion
using namespace std;                //Namespace std definition

void calculate_problem()             //Calculate function with return type void
{
//We can assume that there are 100 bit in vector and 30 are filled as 30% is full
// we will choose 5 numbers/bits from the range 1 to 100.
//We need to find how many times all five bits or numbers are less that 30 for a very big number of trials
int i=0,hit=0;                               //Variable declaration
double prob=0;                           //Variable declaration
while(i<1000000)                        //Number of trials are 1000000
{
int r1=rand()%100+1;
int r2=rand()%100+1;
int r3=rand()%100+1;
int r4=rand()%100+1;
int r5=rand()%100+1;
if(r1 <=30 && r2 <=30 && r3<=30 && r4<=30 && r5<=30)     //Condition checking
{
hit++;                                                                                       //Post increment of hit
}
i++;                                                                                          //Post increment of variable i
}
prob=(double)hit/1000000;
cout<<"Probability of falling in 30% area is "<<prob;              //Printing the probability
}
int main()                                                    //Main function with return type integer
{
calculate_problem();                                                              //Calling the calculate function
return 1;                                                                                 //Returning the value
}

OUTPUT:

I have run the program in online C++ compiler and the screenshot is attached.

29 int r4 rand()%100+1 39 int r5-and ( )%100+1; 31 if(r1 <30 && r2 <-30 && r3<-30 && r4-30 && r5-30) //Condition checking 32

Hope this helps.

Add a comment
Know the answer?
Add Answer to:
Problem 9) Given a biased coin analogy, if a bit vector is 30% full, what are...
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
  • Solve in MATLAB Problem 3: Given the vector x- [2 1 0 6 2 3 5...

    Solve in MATLAB Problem 3: Given the vector x- [2 1 0 6 2 3 5 3 4 1 3 2 10 12 4 2 7 9 2 4 51 use a for loop to (a) Add up the values of all elements in x (b) Compute the cumulative sum, y, of elements in x You can check your results using the built-in functions sum and cumsum. Q.5 What is the value of the sum of elements in vector x?...

  • MATLAB Notes: B) Find likelihood for each sequence 1-9 for each hypothesis. First hypothesis with the...

    MATLAB Notes: B) Find likelihood for each sequence 1-9 for each hypothesis. First hypothesis with the fair coin (theta value = 0.5): what is the probability that we can get each sequence, 1 through 9. Second hypothesis with weighted coin(don’t know theta value): what is likelihood of getting sequence 1 through 9. Using equation to find all possible hundred theta values. For each theta value we need to compute likelihood. Then we sum them up across all possible theta values....

  • In this problem, you will design a 4-bit 2's complement sub tractor, implement it in Logic...

    In this problem, you will design a 4-bit 2's complement sub tractor, implement it in Logic works, and test it. The 4-bit sub tractor works as follows: given two numbers X and Y in 2's complement binary representation on 4 bits, it outputs a 4-bit value representing X - Y in 2's complement. To obtain full marks, the following requirements must be met: You are only allowed to use basic gates, including NOT, AND, OR, NAND, NOR, XOR, XNOR. (You...

  • number 4 and 5 please! PROBLEM STATEMENT A logic circuit is needed to add multi-bit binary...

    number 4 and 5 please! PROBLEM STATEMENT A logic circuit is needed to add multi-bit binary numbers. A 2-level circuit that would add two four-bit numbers would have 9 inputs and five outputs. Although a 2-level SOP or POS circuit theoretically would be very fast, it has numerous drawbacks that make it impractical. The design would be very complex in terms of the number of logic gates. The number of inputs for each gate would challenge target technologies. Testing would...

  • the problem and it's solution is given please derive the steps Problem 4 (30 pts) The...

    the problem and it's solution is given please derive the steps Problem 4 (30 pts) The input to the circuit of the following Figure is a square wave having a period of 1s, maximum value of 5 V, and minimum value of 0 V. Assume all flip-flops are initially in the RESET state +5 V J J J J K K Q K Input pulse train Output # 1 Output #2 Output #3 Output #4 (1) Explain what the circuit...

  • Problem Set 3: (9 pts) This study investigated the cognitive effects of stimulant medication in children...

    Problem Set 3: (9 pts) This study investigated the cognitive effects of stimulant medication in children with Attention-Deficit/Hyperactivity Disorder (ADHD). Shown below are data for the Connors’ Continuous Performance Test (CPT) for 15 children diagnosed with ADHD. This is a visual vigilance task that requires the child to respond to the computer screen any time they see any letter other than “X”. An overall index is calculated that can be used to indicate attention problems based on reaction time, omission...

  • Students must show work to receive full credit. 1. Differentiate “Empirical Probability” and “Classical Probability”. 2....

    Students must show work to receive full credit. 1. Differentiate “Empirical Probability” and “Classical Probability”. 2. Define “Independent Events”, “Mutually Exclusive Events”, and “Collectively Exhaustive Events”. 3. Suppose there are 15 red marbles and 5 blue marbles in a box. (3.a) If an individual randomly selects two marbles without replacement, what is the probability that both marbles are red? (3.b) If an individual randomly selects two marbles with replacement, what is the probability that both marbles are red? 4. Solve...

  • Describe what each code snippet does and how it might be used in Statics. Describe in...

    Describe what each code snippet does and how it might be used in Statics. Describe in general terms what Statics calculation is being performed by each code snippet. What is input to the calculation and what results are given? Give definitions not numbers. Hint: all arrays are components of vectors [ x, y, z ]. Code 1 V1 = [ 0, 1, 2 ]; V2 = [ 3, -4, 5 ]; x = 1; y = 2; z = 3;...

  • please show all work in details Also answer; What is the experiment for this problem? 30....

    please show all work in details Also answer; What is the experiment for this problem? 30. Survey: Customer Loyalty Are customers more loyal in the east or in the west? The following table is based on information from Trends in the United States, published by the Food Marketing Institute, Washington, D.C. The columns represent length of customer loyalty (in years) at a primary super- market. The rows represent regions of the United States. d. May not be copied, scanned, or...

  • Problem 4 (30 pts) This problem explores the sampling theorem and its consequences. Consider the system...

    Problem 4 (30 pts) This problem explores the sampling theorem and its consequences. Consider the system shown in the figure below, where the two input signals are given to be xi(t) = sinc(10t) and x2(t) = sinc(6t). ylt) z(t) LTI →2;(+) ht) Xalt) P(+) - E81-nt) a) State the sampling theorem. Be sure to include all conditions for its validity. (5 pts) b) What is the minimum frequency at which y(t) must be sampled such that it could be completely...

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
ADVERTISEMENT