random integer with sum constraint
On Jan 6, 12:32*pm, "Joe User" <joeu2004 wrote:
"Karin" wrote:
I want to generate two random integers that fall within a certain range
("min" to "max", e.g. 0 to 10) AND that sum to equal no more than a
given value ("maxsum", e.g. 19)
The first integer is easy (using a Analysis Toolpak add-in)
A1=RANDBETWEEN(min, max)
That presumes min+max <= maxsum. *If that assumption is valid in your case,
fine. *Otherwise, I think you should write:
A1: *=RANDBETWEEN(min, MIN(max, maxsum-min))
Example: *if min=1, max=1000 and maxsum=50, random integers from 50 through
1000 are not valid.
Good point. I hadn't thought of that! Since I'm not sure what the
values will always be, I'll update my "easy" first integer. Thanks,
Joe!!!
|