I have a pre specified mean [0.5, 0.5, 0]. This is a probability array which sum up to 1. I want to generate several, say 10 random probability arrays (each sums up to 1) whose mean is [0.5, 0.5, 0], for example out = [[1.41439945e-01 8.58560055e-01 0.00000000e+00] [9.99967956e-01 3.20439716e-05 0.00000000e+00] [9.42136832e-01 5.78631675e-02 0.00000000e+00] [4.40349524e-01 5.59650476e-01 0.00000000e+00] [7.44887609e-01 2.55112391e-01 0.00000000e+00] [2.02038298e-01 7.97961702e-01 0.00000000e+00] [2.87313048e-02 9.71268695e-01 0.00000000e+00] [4.49155118e-01 5.50844882e-01 0.00000000e+00] [9.99805466e-01 1.94534222e-04 0.00000000e+00] [5.14967660e-02 9.48503234e-01 0.00000000e+00]] np.mean(out, axis=0) # [0.5, 0.5, 0] I first generate arrays using arrays = np.random.dirichlet((0.3,0.3,0.3), size=10), such that each row has a sum of 1, but how can I match with the mean? Continue reading...