How about generating the uniform numbers sequentially and keep the running sum
of all the previous numbers. At each step check if the newly generated random
number plus the running sum > 1 discard the number and generate a new one,
repeat the condition check. If the new number plus old sum < 1 a
You want random numbers within the n-dimensional simplex (sum xi <=1)
The easiest solution of course would be creating n-dimensions vectors
with iid uniform components on [0,1) and throwing away those
violating the inequality.
Since the volume of the n-dimensional simplex is 1/n! (factorial)
this b
Hello! I am relatively new using R, but this is my contribution to the
answer. How about using a Monte-Carlo method. Generate m numbers in the
support [0,1], where m>n. Then constrain by constructing a loop that takes
every one of the elements in the m sized vector and select the ones that
sum up t
In the 2 and 3 vector case it is possible do define a fairly simple sampling
space where this is possible.
Consider the unit square where the sample space is the area where x+y <1.
It generalizes to 3 dimensions with no difficulty.
x= (0:100)/100
y= (0:100)/100
z=outer(x,y, function(x,y) 1-
Of course they are random. But they can't all be randomly picked from [0,1).
By scaling them, one is effectively scaling the interval from which they are
picked.
B.
Nb: the scaling procedure will work for any probability distribution.
On Nov 22, 2014, at 10:54 AM, Ranjan Maitra
wrote:
> I d
I don't understand this discussion at all.
n random numbers constrained to have sum <=1 are still random. They are not all
independent.
That said, the original poster's question is ill=formed since there can be
multiple distributions these random numbers come from.
best wishes,
Ranjan
On Sa
These are contradictory requirements: either you have n random numbers from the
interval [0,1), then you can't guarantee anything about their sum except that
it will be in [0,n). Or you constrain the sum, then your random numbers cannot
be random in [0,1). You could possibly scale the random num
(Hit send key by accident before I was finished ...)
Bert Gunter
Genentech Nonclinical Biostatistics
(650) 467-7374
"Data is not information. Information is not knowledge. And knowledge
is certainly not wisdom."
Clifford Stoll
On Sat, Nov 22, 2014 at 7:14 AM, Bert Gunter wrote:
> Well, if th
Well, if their sum must be < 1 they ain't random...
But anyway... given n
randnums <- function(n)
{
Bert Gunter
Genentech Nonclinical Biostatistics
(650) 467-7374
"Data is not information. Information is not knowledge. And knowledge
is certainly not wisdom."
Clifford Stoll
On Sat, Nov 22,
Dear all,
I use R 3.1.1 for Windows.
kindly how can I generate n number of random numbers with probability from [0,1]
and their sum must not be more than one
thanks in advance
Ragia
[[alternative HTML version deleted]]
10 matches
Mail list logo