Question
This Mini Project involves the creation of a structure that will hold a dataset and statistical information about the data set. First, lets describe the
This Mini Project involves the creation of a structure that will hold a dataset and statistical information about the data set. First, lets describe the properties of our structure, Data. Data will have the following properties:
- values: an array of numbers in ascending order
- mean: the sample mean of all the numbers in value
- median: the sample median of all the numbers in value
- variance: the sample variance of all the numbers in value
Note that you can use any variable name for Data in the following functions, but the properties described above MUST be spelled and capitalized EXACTLY as above in order for you to get the last part of this project running. In addition to this, the functions we ask you to write in this project must have EXACTLY the names we ask for in order for the last part of this project to work. The last part is not for a grade, but it is fun for you.
Part 1: Data Structure Creation Function Create a function named createData. createData should take one input: - A number to start your data set off. It should output a data structure, as defined above. values, mean, and median will all be your input number. variance will be 0.
Part 2: Adding New Numbers Create a function called addData. addData should take two inputs in the following order: - A data structure - A new number to add to that data structure It should output the data structure, with the new number included in the array contained by the values property. The number should be included in such a way that the array in values will always be sorted in ascending order. You can assume that the array is already in ascending order when the data structure is given as an input. For example, if the array in values was [1 3 5 7 9], and your input number was 6, the new array would be [1 3 5 6 7 9].
Part 3: Updating Statistics Note that you must accomplish everything in this part of the Mini Project without any built in functions that calculate means, medians, standard deviations, or sums of arrays. There are quite a few functions in MATLAB that do tasks like this. They are all forbidden here. You should focus on using mathematical functions and operators that work on one or two individual numbers, loops, conditional statements, and array indexing. Create a function called updateStats. updateStats should take one input: - A data structure It should output a data structure with a newly calculated values for the mean, median, and variance properties. See Appendix A for information on how to calculate these values. You can use the built-in MATLAB functions mean, median, and var to check your answers, but again, do not use them in the function.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started