HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Volumes > Array and Matrices > problem:


50567 - Input Data Normalization

Volume problems

• 190. 50734 - Product Info (In Srt)
• 200. 50290 - Minimax Sum
• 50332 - Variance of a series
• 50687 - Pascal Triangle - 2
• 50342 - 100 Factorial
• 50337 - Exam Averages
• 51149 - One Piece Arena
• 50558 - Biggest Barn
• 50567 - Input Data Normalization
• 50768 - Where is Waldorf?
• 151. 50557 - nth Power of m (Long...
• 160. 50301 - Fractions to Decimals
• 165. 50360 - National Elections
• 170. 50319 - Toll Plazas
• 210. 50361 - Align Two Lists

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb.
Prepared by Ibrahim Mesecan.

Min Max Normalization

Shqip
In a usage in statistics, when having data examples coming from different sources, in order to be able compare them, they are needed to be normalized . This opeation refers to putting all the data to a common scale in order to negate that variable's effect on the resulting data, thus allowing underlying characteristics of the data sets to be compared. This allows data on different scales to be compared, by bringing them all to a common scale.

There are various normalization methods in statistics: Standard score normalization, Student's t-statistic, nondimensional ratios of errors, residuals, means and standard deviations, etc. The Min Max normalization is also used frequently. In this method min and max of every sample are found first, then, that sample is scaled with the new range according to the following formula:
          (b-a)*(x - min)
   f(x) = -------------- + a
             max - min
where a and b are the min and max of the new range; x is the current value of the data set which is going to be converted to; min and max are the min and max of this data set.
e.g. If we have the data: 5 3 9 7; and we want it to normalize it to the new range 1...4.
   min of the sample data is 3
   max of the sample data is 9
   a (min of the new range) is 1
   b (max of the new range) is 4
   The element value that we will convert: x (the first element of data series) is 5
Then 5 (the first element of the data series) can be converted with the following formula:
          (4-1)*(5 - 3)
   f(5) = -------------- + 1 = 2
             9 - 3
After normalizing all the elements the new data series will be:   2 1 4 3;

Question

Write a program that is going to read a two dimensinal array, and it will normalize all data to the given scale.
(All the rows will be normalized independently to the given scale.)

Input specification

The first line contains four numbers m, n, a, b.
   m is (integer) the length of the input array where 1 ≤ m ≤ 25,
   n is (integer) the height of the input array where 1 ≤ n ≤ 3000,
   a, b are (floating point numbers) the min and max of the new range where -10000 ≤ a, b ≤ 10000)).
Starting from the second line, we will have m numbers in the following n lines representing the input data. The values stored in the input array A[n][m] will be integers in the range from   -150000 to  +150000,

Output specification

Give the normalized array m numbers in n lines in the same order as the input data. Each number in the line will be separated by a space. Output numbers' data type will be double with at most 3 digit precision.
When calculating the 3 digit precision, the 4th digit will be rounded (up or down) to the third digit.

Sample Run

Sample Input 1 Sample Output 1
4 5 1 10
1 0 2 3
8 4 7 5
2 0 3 2
5 5 3 2
5 4 5 5
4 1 7 10
10 1 7.75 3.25
7 1 10 7
10 10 4 1
10 1 10 10
Sample Input 2 Sample Output 2
3 6 0 1
5 4 1
5 9 6
-3 -3 0
8 3 6
13 11 12
4 6 10
1 0.75 0
0 1 0.25
0 0 1
1 0 0.6
1 0 0.5
0 0.333 1

Для отправки решений необходимо выполнить вход.

www.contester.ru