I have a four column matrix with missing data, each represented by “x”
ImportString["12\t27\t19\t44
11\tx\t13\t43
x\t56\t23\t60
15\t37\t19\t52
10\t31\t21\tx
18\t40\t22\t43
15\t50\t28\t56
21\tx\tx\t46
20\t39\t25\t51
x\t36\t23\t56
x\t27\t21\t39
14\t32\t20\t46
22\t40\tx\t49
x\t31\tx\t44
x\t18\t21\tx
16\t23\t21\t34
27\t26\t23\t59
17\tx\tx\t35
13\t21\t20\t48
11\t51\t18\t54
", "TSV"];
I need to replace each “x” with a Random Variate from a distribution that is specific to each column (the parameters are determined by mean and variance in actual observed data in each column)
It seems that, for the first column,
If[# == "x",
ReplacePart[
data[[All,1]], # -> RandomVariate[NormalDistribution[0, 1]]]] &
should work, but it doesn’t.
Once that issue is solved the four different parameter sets for the four distributions needs to be threaded over the four columns.