I would like to create a 2 dimensional numpy array M
of size n,n
(a square matrix M
that is) with the following constraints:
- The sum of each row equals to one
- The elements of each row are all between 0 and 1
- (Bonus) The value of row
i
that dominates is located at entryM[i,i]
.
For example, for a square matrix it would be something like M = np.array([[0.88,0.12],[0.13,0.87]])
- Ideally I want the entries of each row to follow some Gaussian like distribution whose peak, for row
i
, is located at elementM[i,i]
.
In this SO thread a similar question is asked. However, playing with the responses there I was not able to find a way to do it. This is a search problem, and I do understand it might be formulated as an optimization problem. However, I am wondering if these constraints can satisfied without the need of some specialized solver.
Aucun commentaire:
Enregistrer un commentaire