Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

MATLAB 1. Statistical properties of a data array Write a function, stats.m, that takes an array X of numbers as input, determines the following statistical

MATLAB

1. Statistical properties of a data array Write a function, "stats.m", that takes an array X of numbers as input, determines the following statistical properties (by calling sub-functions), and then outputs the results in a nice table. a. Minimum and Maximum b. 1st and 3rd Quartiles c. Median (2nd Quartile) d. Mean (a.k.a Average) e. Variance and Standard Deviation

The calculation of these quantities should be organized into sub-functions, in an efficient way.

The main code (script), "lab10.m" will create the array(s) and then passes it to your "stats" function.

The "stats.m" function should take a single vector as input, pass it to the sub-functions to calculate these values. Then it should print out the results in a nice, neat table.

The sub-functions should only calculate values and return them to the stats function. They should not print anything.

Each code should be documented with appropriate brief comments. 2. Statistics: For an array X of N numbers:

The maximum, Max, and minimum, Min, are the largest and smallest values in the list. You can use your "sorting" (bubble-sort), or Matlab's "sort", to find them.

The 1st Quartile is a value Q1 such that 25% of the data is below it and 75% is above. If your data is in sorted order, you can find Q1 from the index. Try out a few examples by hand to see how it works. The value may either be one of the values in the array, or some average of two neighboring values.

Similarly, the 3rd Quartile is a value Q3 such that 75% of the data is below it and 25% is above.

The Median, Q2, is the middle point with 50% below and 50% above (the 2nd quartile). If N is odd, then Q2 is one of the values. If N is even, then Q2 is the average of the two middle values.

The Mean, Avg, is the sum of the values divided by the total number.

The Variance, Var, is the average squared deviation of elements from the Mean. i.e. the sum of the squares of the differences between the elements and the Mean, divided by the number of elements N. (This is the population variance. For the sample variance the sum would be divided by N1).

The Standard Deviation, StDev (commonly denoted by ), is the square root of the Variance. 3. To do:

Your main code will create two data arrays and pass each to the "stats.m" function that calculates all the stats and displays the results. The first array is X = 10*cos(1:10) . The second array Y should have 41 entries, each a random integer between 20 and 100 (inclusive).

Do not use any built-in MATLAB statistics functions for your calculations. Code them all yourself.

A good way to display the stats of an array would be: Min, Max, Avg: value, value, value Q1 , Q2, Q3 : value, value, value Var, StDev : value, value

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David M. Kroenke, David J. Auer

7th edition

133544621, 133544626, 0-13-354462-1, 978-0133544626

More Books

Students also viewed these Databases questions