0% found this document useful (0 votes)
55 views

MATLAB Homework 5: Exercise 5. 1 Load and Convert Data (2pts)

This document provides instructions for MATLAB homework on loading and analyzing construction duration data. Students are asked to: 1) Load duration data from a CSV file and convert it to days. 2) Calculate summary statistics of the data including the mean, median, mode, and standard deviation. 3) Fit the data to a normal distribution and plot the histogram and density function. 4) Use the normal distribution to find a target project completion time given an upper tail probability. The document provides guidance on formatting outputs and submitting the MATLAB code.

Uploaded by

Riaz Ahmad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views

MATLAB Homework 5: Exercise 5. 1 Load and Convert Data (2pts)

This document provides instructions for MATLAB homework on loading and analyzing construction duration data. Students are asked to: 1) Load duration data from a CSV file and convert it to days. 2) Calculate summary statistics of the data including the mean, median, mode, and standard deviation. 3) Fit the data to a normal distribution and plot the histogram and density function. 4) Use the normal distribution to find a target project completion time given an upper tail probability. The document provides guidance on formatting outputs and submitting the MATLAB code.

Uploaded by

Riaz Ahmad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

MATLAB Homework 5 Prof.

Oke
CEE 260/MIE 273 Probability & Statistics in [Civil] Engineering 10.17.2019

Objectives
Practice loading data and computing summary statistics. Introduction to normal distribtuion
computation in MATLAB; plotting a normal distribution.

Prompt
The included CSV file contains the average construction duration (in months) of residential dwellings
in the United States from 1971 to 2009.

Exercise 5. 1 Load and convert data (2pts)


Use the csvread function and the appropriate range specification to obtain a 1D array of the
construction times. Convert the values into days (assume 1 month is 30 days). All the preceding
exercises assume you are working with the dataset of durations already converted to days.

Exercise 5. 2 Summary statistics (4pts)


The summary statistics of a dataset include measures of location (mean, median, mode) and disper-
sion (standard deviation, etc). Find the (a) mean, (b) median (c) mode and (d) standard deviation
of the length of time of construction (in days). Format your responses properly using fprintf or
disp statements.1 (What do you notice about the measures of location/central tendency?)

Exercise 5. 3 Fitting a normal distribution (9pts)


In a set of normally distributed variables, the measures of central tendency are equal. Given
your answers in Exercise 5.2, would you agree that this dataset can be approximated by a normal
distribution?

(a) Use the normfit function to find the estimated parameters (mean and standard deviation) of
the normal distribution fit to this dataset. Properly format your answer. (Do your results show
any similarity to the summary statistics?)

(b) Use the histfit function to display a histogram of the data and fitted normal probability
density function. (Be sure that you understand this plot. Observe that the y-axis values of the
histogram and curve do not coincide.)

(c) Now create your own density plot of the estimated normal distribution with the normpdf
function and your results from (a), using a reasonable x-axis range (a possible range has been
given in the template). Properly label both axes and title the plot. You may use plot arguments
such as ‘LineWidth’ and post-plot commands such as grid on to enhance your plot.

1
See note on fprintf vs. disp on Page 2.
Page 2 Oke

Exercise 5. 4 Find normal variable given upper tail probability (4pts)


Assume the duration of recent residential dwellings across the country still follow the same distri-
bution. If the probability of delay in completing a residential construction project is 0.23, find the
target completion time in months. You must have at least one statement in your .m file showing
your computation. However, you may use as many statements as you like. Properly format your
answer. (Hint: The norminv function may be useful. Look up the documentation for help.)

Note about questions


The required output in this homework is clearly indicated by the phrases “format your answer”,
“format your responses”, “display”, etc. Any parenthetical questions are there to improve your
understanding and spur your thinking. No output is required for these.
In Exercise 5.3(b), histfit produces only one plot (the fitted normal curve superimposed onto
the histogram).
In displaying and formatting your responses, full sentences are required. While it is prefer-
able and more straightforward to use fprintf, you can also achieve similar results with disp.
However, this might mean using sprintf to format the text first. Thus, both

1 f p r i n t f ( ' The s t a n d a r d d e v i a t i o n i s %5.2 f days \n ' , stdT ) ;

and

1 x = s p r i n t f ( ' The s t a n d a r d d e v i a t i o n i s %5.2 f days ' , stdT ) ;


2 disp (x) ;

will produce the same result:

1 The s t a n d a r d d e v i a t i o n i s 1 7 . 3 7 days

One interesting feature of disp is that you do not need to end the text with the newline character
\n.

Submission instructions
Append your name to HW5.m with an underscore (deleting template from the filename). Note that
MATLAB filenames must begin with a letter and contain only letters, numbers and underscores.
Modify the template file as brutally as you wish, as long as your submission produces the required
output as specified in the Exercises. Before you submit, make sure that your .m file produces all
the required (properly formatted) output (including the plots).
Tip: To run your .m file from the MATLAB Command Window, simply enter the filename
(without the extension).

HW 5 CEE 260/MIE 273

You might also like