Question: Introduction to Programming - Lab Manual Statistical Analysis ( While Loop ) [ Execute this question in a new script named Iname _ fname _

Introduction to Programming - Lab Manual
Statistical Analysis ( While Loop )
[Execute this question in a new script named "Iname_fname_lab4_stat_1.m"]
a) Problem: Implement an algorithm that reads in a set of measurements and calculates the
mean and the standard deviation of the input data set.
b) Be sure your program can handle if there is '0' or '1' input. (Hint: Use an if construct. If
there are less than '2' inputs, display "Insufficient information" and exit. If there are
more than two inputs, go on your program.)
% Define variables:
%n-- The number of input samples
dev -- The standard deviation of the input samples
sum_?-x-- The sum of the input values
sum -- The sum of the squares of the input values
x- An input data value
xbar -- The average of the input samples
Background
The average or arithmetic mean of a set of numbers is defined as
x=1Ni=1Nxi
where xi is sample i out of N samples.
The standard deviation of a set of numbers is defined as
s=i=1N(xi-(x))2N2
Standard deviation is a measure of the amount of scatter on the measurements; the greater
the standard deviation, the more scattered the points in the data set are.
Introduction to Programming - Lab Manual
Pseudocode:
STEP -1: Accumulate input data
Initialize n to zero, initialize array numbers_x to 0 dimension array.
Prompt user for first positive number and note that "Entering -1 will end the process."
Read in first x
while x0
@,nlarrn+1
@ sumx[n]=x
sum_x[n]= x
Prompt user for next number
Read in next x
End
STEP -2: Calculate mean and Standard Deviation
,x?bar larr sum_x / n
std_dev larr sqrt( FILL IN THE BLANKS )
STEP -3: Write Out the results
Write out the mean value x_bar
Write out the standard deviation std_dev
Write out the number of input data points n
Additional Questions:
List the conditions when above program will fail.
How can you avoid these possible errors programmatically and change "-1" exit flag to
any letter?
 Introduction to Programming - Lab Manual Statistical Analysis ( While Loop

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!