Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Random numbers generation with variable bound
Replies: 3   Last Post: Jan 16, 2014 6:32 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Torsten

Posts: 1,477
Registered: 11/8/10
Re: Random numbers generation with variable bound
Posted: Jan 16, 2014 5:03 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Simone" wrote in message <lb888f$enq$1@newscl01ah.mathworks.com>...
> I need to create a vector of N random numbers x(N) that satisfies the following constraints:
>
> sum x(i) = s
> lb(i) < x(i) < ub(i) for i ? {1...N}
>
> where s is a scalar and lb(N) and ub(N) are vectors.
>
> Note that the lower and the upper bounds are different for each i. I found randfixedsum function but the upper and lower bounds have to be the same for each number.
>
> How can i solve this problem?


Take a look at
https://www.mathworks.com/matlabcentral/newsreader/view_thread/324503
1. Divide your bounds by s
2. Generate a random vector x~ with the code above
3. Set your x to s*x~.

Best wishes
Torsten.



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.