Click on the Tools menu, then select Data Statistics. The menu appears as shown in Figure 7.1-5. The tool is accessed from the Figure window after you plot the data. With the Data Statistics tool you can calculate statistics for data and add plots of the statistics to a graph of the data. of the bin centers the bin widths are the distances between the centers. The third form is hi s t (y r x) ,where x is a user-specified vector ,that determines the location. n is a user-specified scalar indicating the number of bins. The second form is hist (y, n ), where . This form aggregates the data into 10 bins evenly spaced between the minimum and maximum values in y. Its basic form is hi s t (y) ,where y is a vector containing the data. MATLAB provides the hi s t command to generate a histogram. We have selected the bin centers to be in the middle of the ranges 60-69, 70-79, 80-89, 90-99. The MATLAB script file that generates Figure 7.1-1 follows. The function bar (x I Y} creates a bar chart of y versus x. Use the bar function to plot the number of values in each bin versus the bin centers as a bar chart. bin centers and count the number of values in each bin. To obtain a histogram, first sort the data if it has not yet been sorted (you can use the sort function here).
If the number of data values is relatively small, the bin width can not be small because some of the bins will contain no data and the resulting histogram might not usefully illustrate the distribution of the data. The choice of the bin width and bin center can drastically change the shape of the histogram. To plot a histogram, you must group the data into sub ranges, called bins. On the first test we.say that the scores are evenly, or “uniformly,” distributed between 60 and 100, whereas on the second test the scores are more clustered around the mean. However, the distribution of the scores is very different. The mean on both tests is identical and is 79.75. The histogram for these scores is shown in the bottom graph in Figure 7.1-1. On this test there are two scores in the 60-69 range, nine in the 70-79 range, seven in the 80-89 range, and two in the 90-100 range. Suppose that on the second test the following 20 scores were achieved: It is a bar plot of the number of scores that occur within each range, with the bar centered in the middle of the range (for example, the bar for the range 60-69 is centered at 64.5, and the asterisk on the plot’s abscissa shows the bar’s center).įigure 7.1-1 Histograms of test scores for 20 students.
The histogram for these scores is shown in the top graph in Figure 7.1-1. On this test there are five scores in the 60-69 range, five in the 70-79 range, five in the 80-89 range, and five in the 90-100 range. For example, suppose that in a class of 20 students the 20 scores on the first test were A histogram is a.plot of the frequency of occurrence of data values versus the values themselves. The way the data are spread around the mean can be described by a histogram plot. The first set of scores vary over large range, whereas in the second set-the scores are tightly grouped about the mean. For example, the test scores 60, 65, 68, 74, 88,95 have the same mean , as the scores 71, 72, 73, 77, 78, 79, but the two sets describe very.different test outcomes.
Two data sets can-have the same mean (or the same median) yet be very different. In many applications, the mean and the median do not adequately describe a data set. These functions do not require the elements in x to be sorted in ascending or descending order. However, if x is a matrix, a row vector is returned containing the mean (or median) value of each column of x. If x is a vector, the mean (or median) value of the vector’s values is returned. MATLAB provides the mean(x) median (x) functions to perform _these computations. For example, for the data 65, 68, 74, 88, 95, the mean is 75, whereas the median Little mean of 68 and 74 or 71. The mean need not be the,same as the median. For example, if the test on a particular test in a class of 27 students have a median of 74, then 13 students scored below 74 13 scored above 74, and one student obtained a grade number of data points is even, the median is the mean of the two ‘values close the middle. On the other hand, the median is the value in the of the data if the number of data points is odd. The mathematical term for this average is the mean. To find your average, you add your scores and divide by the number of tests.
In all likelihood you have computed an average, for example, the average of all your test scores in a course.