File Exchange Pick of the Week

Uniform random samples with fixed sum 5

Posted by Michelle Hirsch,

Thanks again to guest-picker-in-residence John D’Errico …

Yes, I’ll admit that I’m one of those people who enjoys a pretty piece of mathematics. Its something you will find in a randfixedsum, by Roger Stafford. Roger managed to find a way to compute uniform random samples that lie inside a hypercube, but still satisfy a sum constraint on the samples. Yes, I had figured out how to do that in 2 or 3 or 5 dimensions, but I was totally stymied when I tried to push my approach to higher numbers of dimensions. Roger’s code works (efficiently!) in higher dimensions with ease.

Its definitely not something you would need to use every day, but its worth a peek.

5 CommentsOldest to Newest

These postings are the author's and don't necessarily represent the opinions of MathWorks.