Reputation: 145
I want to generate a matrix of random numbers (normrnd
with mean == 0
) that satisfy the following constraints using MATLAB (or any other language)
X
abs(single number)
must equal Y
Z
It would be relatively easy to satisfy one of the constraints, but I can't think of an algorithm that satisfies all of them...
I am not sure whether to edit my post or to reply here, so I am editing... @MZimmerman6, you have a point. Though these constraints won't produce a unique solution, how would I obtain multiple solutions without using rand?
A very simply 3 x 3 where 5 is the max element value, 30 is the sum, and 2 is the difference
5 4 3
4 4 2
3 2 3
Rody, that actually may help...I need to think more :)
Luis ...Hmmm...why not? I can add up the absolute value of a normally distributed sample...right?
Upvotes: 2
Views: 1009
Reputation: 21561
Here is an algorithm to get the 'random' numbers that you need.
Depending on your constraints it may take a while of course. You could add an other step to see if changing the existing numbers would help before going back to step 1.
Upvotes: 1