OK, to move these efforts along (but with some diffidence) I offer this approach: generate the diagonal elements first. Make them large constants. Generate all off-diagonal elements iid according to any (non-negative) distribution you want. Normalize rows. Check the column-max condition. Repeat if violated.
By making the initial constants sufficiently large, the expected number of repetitions can be made small.
Clearly the diagonal elements are iid, the non-diagonal elements are iid, but (of course) the two distributions differ.
Here's some code to play with.
n <- 8 # Matrix dimension
y <- rep(1 + 3/sqrt(n),n) # A large constant compared to entries in x
x <- matrix(runif(n^2), ncol=n) # Here, uniform distributions off diagonal
x[cbind(1:n,1:n)] <- y # (Paste in the diagonal)
z <- t(apply(x, 1, function(u) u/sum(u))) # Normalize the rows
which(1:n != apply(z, 2, which.max)) # Find all columns violating the conditions
(One hopes for integer(0)
as the output; otherwise, indexes of columns whose maxima are not diagonal will be output.) I have experimented with n
ranging from 3 through 300.
It's instructive to plot the columns:
plot(z[1,], type="n")
apply(z, 2, function(u) lines(u, col=(256*runif(1))))
Best Answer
If I understand you correctly, only points in some small volume of n-dimensional space meet your constraints.
Your first constraint constrains it to the interior of a hypersphere, which reminds me of the comp.graphics.algorithms FAQ "Uniform random points on sphere" and How to generate uniformly distributed points in the 3-d unit ball? The second constraint slices a bit out of the hypersphere, and the other constraints further whittle away at the volume that meets your constraints.
I think the simplest thing to do is one of the approaches suggested by the FAQ:
With sufficiently high-quality random number generator, this gives you a set of stored coordinates that meet your criteria with (expected) uniform density.
Alas, if your have a relatively high dimensionality n (i.e., if you construct each vectors out of a relatively long list of coordinates), the inscribed sphere (much less your whittled-down volume) has a surprisingly small part of the total volume of the total bounding box, so it might need to execute many iterations, most of them generating rejected points outside your constrained area, before finding a point inside your constrained area. Since computers these days are pretty fast, will that be fast enough?