(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
C++ for Engineers and Scientists
- vatches? (2 pts.) 7. Find the probability that number 5 appears only once when a fair die is tossed 4 times.arrow_forward5. Let X be the random variable that represents the number of hearts in a 4 card hand drawn from a standard deck. (a) What is the probability distribution of X? (b) What is the expected value of X?arrow_forwardIncident Computation The sum of the years “at risk” of these 12 courses is 102 students-years, and there were 3 occurrence of disease. We can now compute the incident rate: (One decimal place only. No need to include “%” sign to your answer.)arrow_forward
- The following equations estimate the calories burned when exercising (source): Women: Calories = ( (Age x 0.074) — (Weight x 0.05741) + (Heart Rate x 0.4472) — 20.4022 ) x Time / 4.184 Men: Calories = ( (Age x 0.2017) + (Weight x 0.09036) + (Heart Rate x 0.6309) — 55.0969 ) x Time / 4.184 Write a program using inputs age (years), weight (pounds), heart rate (beats per minute), and time (minutes), respectively. Output calories burned for women and men. Output each floating-point value with two digits after the decimal point, which can be achieved as follows:print('Men: {:.2f} calories'.format(calories_man)) Ex: If the input is: 49 155 148 60arrow_forwardThe following equations estimate the calories burned when exercising (source): Women: Calories = ( (Age x 0.074) — (Weight x 0.05741) + (Heart Rate x 0.4472) — 20.4022 ) x Time / 4.184 Men: Calories = ( (Age x 0.2017) + (Weight x 0.09036) + (Heart Rate x 0.6309) — 55.0969 ) x Time / 4.184 Write a program using inputs age (years), weight (pounds), heart rate (beats per minute), and time (minutes), respectively. Output calories burned for women and men. Output each floating-point value with two digits after the decimal point, which can be achieved as follows:print('Men: {:.2f} calories'.format(calories_man)) Ex: If the input is: 49 155 148 60 Then the output is: Women: 580.94 calories Men: 891.47 caloriesarrow_forwardInformation on morphine: Morphine can be administered via injection / IV. The quantity of morphine in a given dose may vary, but one guideline is to use 0.1 mg of morphine for each kg of the patient's body mass. The time taken for half the quantity of morphine to be removed from the body is 2 hours. An exponential function can be used to model the amount of morphine in the body over time: ?=?0???A=A0ekt (note that ?k will be negative). Calculate the value of ?k for morphine. Write a Python function called MorphineModel, which takes two arguments: dose amount ?0A0 and time since last dose ?t, and returns the amount of morphine in the body at this time ?t. Add to your computer code so that you have a program which is an implementation of the following flowchart. Ensure that your code is well-communicated to a user of the program (via the print statements) and well-communicated to someone reading the code (via comments).arrow_forward
- The following equations estimate the calories burned when exercising (source): Women: Calories = ( (Age x 0.074) — (Weight x 0.05741) + (Heart Rate x 0.4472) — 20.4022 ) x Time / 4.184 Men: Calories = ( (Age x 0.2017) + (Weight x 0.09036) + (Heart Rate x 0.6309) — 55.0969 ) x Time / 4.184 Write a program with inputs age (years), weight (pounds), heart rate (beats per minute), and time (minutes), respectively. Output calories burned for women and men. Output each floating-point value with two digits after the decimal point, which can be achieved by executingcout << fixed << setprecision(2); once before all other cout statements. Ex: If the input is: 49 155 148 60 the output is: Women: 580.94 calories Men: 891.47 caloriesarrow_forwardUsing the Gaussian Probability Density function write a function that will calculate the probability that variable x will be in the range µ − ασ < x < µ + ασ, where α is some multiple of the variance.arrow_forwardQ1/The pressure drop in pascals (Pa) for a fluid flowing in a pipe with a sudden decrease in diameter can be determined based on the loss of head equation given below: h = 24-11 2g Area A Area A Area A Where: V₂ is the velocity in position 2 (m/s), g: is acceleration due to gravity = 9.81 m/s², A₁ and A₂ are the cross-sectional areas of the tube in position 1 and 2 respectively. A==d² Where: d is the diameter (m). Write a program in a script file that calculates the head loss. When the script file is executed, it requests the user to input the velocity (V₂) in m/s and values of diameters (d, and d₂). The program displays the inputted value of v followed by a table with the values of diameters in the first and second columns and the corresponding values of h, in the third column. 2 2arrow_forward
- Graph the following functions and determine whether the functions are even, odd or neither: (a) y = sin x (b) y = sec xarrow_forwardProbability and Statistics I have in my pocket ten coins. Nine of them are ordinary coins with equal chances of coming up head and tail when tossed and the tenth has two heads. If I take one of the coins at random from my pocket, what is the probability that it is the coin with two heads ?arrow_forwardDetermine the drag coefficient c needed for a parachutist of mass m=68.1kg to have a velocity of 40m/s after free-falling for time t=10s. Note: The acceleration due to gravity is 9.8m/s2. Use the Regula Falsi methodarrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr