Question
There are a number of ways to normalize, or scale, a set of values. One common normalization technique scales the values so that the minimum
There are a number of ways to normalize, or scale, a set of values. One common normalization technique scales the values so that the minimum value goes to 0, the maximum value goes to 1, and the other values are scaled accordingly. Using this normalization technique, the values of the array below are normalized.
Original Array Values
-1 | -2 | 2 | 0 |
Normalized Array Values
0.25 | 0.0 | 1.0 | 0.5 |
The equation that computes the normalized value from a value xk in the array is the following
Normalized xk = (Xk-minx)/(maxx-minx)
Where minx and maxx represent the minimum and maximum values in the array x. If you substitute the minimum value for xk in the equation, the numerator is zero, thus, the normalized value for the minimum is zero. If you substitute the maximum value for xk in this equation, the numerator and the denominator are the same value; hence the normalized value for the maximum is 1.0.
Write and test a main program that has a one-dimensional double array. The maximum number of values that this main array can store is 25. The main program should use several programmer-defined functions. Create programmer-defined functions called get_array, display_array, array_max, array_min, and norm. Prompt user to input original array values and print out normalized array values on console.
Programmer-defined function get_array will read elements of and the number of values in the array as its arguments. Normalize the values in the array using the technique describe above. Use the function array_max that was developed in Chapter 5 to find out the maximum values in array x. Create function array_min to find out the minimum values in array x. Assume that the function prototype if the following:
void norm(double x[], int npts) ;
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