(Probability) The probability that a phone call will last less than t minutes can be pproximated by the exponential probability function:
Probability that a call lasts less than t
For example, assuming the average call length is 2 minutes, the probability that a call will last
less than 1 minute is calculated as
C++
Program plan:
- Include the header files and using the namespace for standard I/O.
- Define the main function.
- Declare the variables x and z of integer type and y of double data type.
- Declare the essential variables.
- Use the loop to iterate.
- Calculate the probability that the call last less than t minutes.
- Display the list of probabilities in tabular format
Program description:
The main purpose of the program is to calculate theprobability of that a call will last less than one minute. This is calculated by the below formula: -
Explanation of Solution
Program:
//Importing the essential headers #include <iostream> #include <iomanip> #include <math.h> //Using the namespace for standard I/O usingnamespacestd; //Defining the main function intmain() { //Declaring the essential variables double p;//to store the Probability double e =2.71828;//to store the Euler’s number int a=2;//to store the average call length cout<<"Call Time\tProbability\n"; //Using the loop to iterate for(int t =1; t <10; t++) { //Calculating the probability that the call last less than t minutes p =1-pow(e,(-1*t)/(a)); //Displaying the list of probabilities in tabular format cout<<setprecision(0)<< fixed << t <<"\t\t"<<setprecision(4)<< p <<endl; } }
Sample output:
Want to see more full solutions like this?
Chapter 5 Solutions
EBK C++ FOR ENGINEERS AND SCIENTISTS
- Need help with the following code I'm not sure if I'm doing it right and also getting an error: simulate a ping pong game with one of the above mentioned random number generator - system random function with seed = 5, and compute the probability you win a ping pong game up to n points, when your probability of winning each point is p (and your friend wins the point with probability 1 − p). Assume you have to win by (at least) 2; for example, if n = 21 and the score is 21 - 20, the game isn't over yet. - Simulate ntrials = 5, 000 games, and make a single plot with the x-axis being p for different values of p in {0, 0.04, 0.08, · · · , 0.96, 1.0} and the y-axis being the probability of winning the overall game (use your previous function). Plot 3 "curves" in different colors, one for each n in 3,11,21. - Identify the interesting pattern you notice when n gets larger (regarding the steepness of the curve), and explain why it makes sense. - Each curve you make for different values of n…arrow_forwardFor every of 4 statements prove its correctness.arrow_forwardGraph the following functions and determine whether the functions are even, odd or neither: (a) y = sin x (b) y = sec xarrow_forward
- 1. Use R programming code to answer these questions:- a) A particular treatment is effective in 80% of cases. The treatment is given to 5 patients. What is the probability that the treatment will be effective for exactly 4 of the patients? For at least 4 of the patients? What is the probability that the treatment will be effective for 2 or fewer cases? b) Suppose 20% of individuals exposed to a particular contaminant develop a certain condition. For a group of 200 exposed individuals, what is the probability that at least 30 develop the condition? What is the probability that between 30 and 40 (inclusive) develop the condition? For these calculations, use the normal approximation to the binomial distribution.arrow_forward1. Prove the following formulas log X < X for all X > 0arrow_forward1 Simplify the following expressions. Here, b is a variable of type booleaarrow_forward
- (Thermodynamics) The work, W, performed by a single piston in an engine can be determined by this formula: W=Fd F is the force provided by the piston in Newtons. d is the distance the piston moves in meters. a. Determine the units of W by calculating the units resulting from the right side of the formula. Check that your answer corresponds to the units for work listed in Table 1.1. b. Determine the work performed by a piston that provides a force of 1000 N over a distance of 15 centimeters.arrow_forward3- The variation of specific volume (ν) internal energy (u) enthalpy (h) and entropy (s) of superheated water with temperature at P=0.01 MPa pressure are presented in the table. By using this data, rebuild the given table for ν, u, h and s between T=50 °C and T=500 °C with ΔT=10 °C steps by using Newton’s divided difference interpolating polynomials. Present your results in a new table.arrow_forwardDetermine if the following argument is valid or invalid. State if valid or invalid and the the law or fallacy used to support your answer. [(¬p → q) ∧ q] → ¬parrow_forward
- Determine whether the following statements are logically equivalent using truth tables.¬ (p → q) and (p ⊕ ¬q)arrow_forwardExplain the Wronskian determinant test. Using the Wronskian determinant test, write the program using NumPy to determine whether the functions f(x)=e^(- 3x), g(x)=cos2x and h(x)=sin2x are linearly independent in the range (-∞, + ∞). #UsePythonarrow_forwardLet Σ = {0} and consider the following function f : Σ+ → Σ+arrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr