I have read various articles talking about standardization and normalization but none of the offers a concrete example on how to rescale data using their formulas.
I would like to transform data as follows; given data = [x1...xn] rescale(data,n) should it rescale it to n whilst retaining distribution for example
eg_1 = np.array([1]) -->rescale(eg, 2) -->[0.5, 0.5]
eg_2 = np.array([1,1]) -->rescale(eg_2, 4) -->[0.5,0.5,0.5,0.5]
eg3 = np.array([0,1]) --> rescale(eg_3,4) --> [0,0,0.5,0.5]
If possible, I would also like for the inverse to be true, for example
inv_eg1 = np.array([0.5,0.5,0.5,0.5]) --->inv_rescale(inv_eg1,2) --> [1,1]
My initial attempt was simply the formula, (sum of variables in the array/total length of array) * range no. of desired range = value at range no position. but unfortunately, it not retain the distribution.
The purpose is, I want to apply various kernels and matrices of different shapes but i do not want to use padding.
Please help