0
$\begingroup$

Suppose I have the following dataset:

import numpy as np
a = np.array([ 0.00854492,  0.00622559,  0.01733398,  0.04077148,  0.03027344,
        0.04418945,  0.07006836,  0.04626465, -0.00158691,  0.04345703,
        0.06213379,  0.0300293 ,  0.05517578,  0.02636719,  0.05688477])

a.mean()
0.035742187999999994

a.std()
0.020752584616225259

How can I transform the dataset so that it has a mean of 0.04 and std of 0.015?

$\endgroup$
0
1
$\begingroup$

It may be useful to know for what purpose you need to make such a transformation, since my first thought is why not generate a data set with your specific parameters?

$\endgroup$
2
  • $\begingroup$ Hey @Konchshell, thanks for the reply. The purpose of this transformation is to normalize the predictions from a ML model so I can't generate a data set with these parameters. $\endgroup$
    – Allen
    Jun 8 '17 at 1:45
  • 1
    $\begingroup$ You should be able to multiply by 0.04/0.0357 (a.mean) to get the mean you want, it's a simple scaling operation. But changing the SD I'm not sure about, that is actually changing the information contained in the data set, it would not be the same data anymore. $\endgroup$
    – Konchshell
    Jun 8 '17 at 1:48

Not the answer you're looking for? Browse other questions tagged or ask your own question.