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 mn. 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
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
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
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,
(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 bgun...@gene.com
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
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
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
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)
On Fri, 27 Apr 2012, Vale Fara wrote:
I am working with lotteries and I need to generate two sets of uniform
random numbers.
Requirements:
1) each set has 60 random numbers
random integers?
2) random numbers in the first set are taken from an interval (0-10),
whereas numbers in the second
Interesting set of question.. I am completely new to R but let me try my
luck.
Random number in R
x - runif(60 , 0 , 10) # 60 numbers from 0 to 10
y- runif(60, 15 , 25) # same as above , from 15 to 25
The second part though. Do you mean ,
for( i in 1:length(x)) {
z = x[i] + y[i]
return z
}
On Apr 29, 2012, at 2:25 AM, billy am wickedpu...@gmail.com wrote:
Interesting set of question.. I am completely new to R but let me try my
luck.
Random number in R
x - runif(60 , 0 , 10) # 60 numbers from 0 to 10
y- runif(60, 15 , 25) # same as above , from 15 to 25
The second
Hi,
thank you both for your replies, I really appreciate it!
To Mike: yes, random integers. Can I use the function round() as in
the example with 5 random numbers below?
To Billy: for the second part I got an error, but it may be that I
didn't properly set i...?
Here is the R output:
x -
I would assume that you would use 'sample' to draw the numbers:
sample(0:10,60,TRUE)
[1] 2 3 1 2 9 2 2 0 3
[10] 0 4 2 3 9 7 3 10 9
[19] 8 5 8 7 6 3 10 0 6
[28] 8 10 6 3 3 2 7 0 0
[37] 1 4 8 2 10 2 0 7 9
[46] 9 9 7 9 6 10 1 1 6
[55] 1 8 3 8 2
On Sun, Apr 29, 2012 at 4:38 PM, Vale Fara vale...@gmail.com wrote:
Hi,
thank you both for your replies, I really appreciate it!
To Mike: yes, random integers. Can I use the function round() as in
the example with 5 random numbers below?
To Billy: for the second part I got an error, but it
On Mon, 30 Apr 2012, Vale Fara wrote:
ok, what to do is to generate two sets (x,y) of integer uniform random
numbers so that the following condition is satisfied: the sum of the
numbers obtained in x,y matched two by two (first number obtained in x
with first number obtained in y and so on)
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of Mike Miller
Sent: Sunday, April 29, 2012 5:21 PM
To: Vale Fara
Cc: r-help@r-project.org; billy am
Subject: Re: [R] generate random numbers for lotteries
On Mon, 30 Apr 2012
On Sun, 29 Apr 2012, Daniel Nordlund wrote:
I don't know what the OP is really trying to accomplish yet, and I am
not motivated (yet) to try to figure it out. However, all this
flooring and ceiling) and rounding is not necessary for generating
uniform random integers. For N integers in the
There are several non-normal distributions built in that you could just use
their generationg functions. There are packages (most with dist somewhere in
the name) that allow for functions on standard distributions including
combining together distributions.
If your distribution is not one of
On 31-Mar-11 19:23:33, Anna Lee wrote:
Hey List,
does anyone know how I can generate a vector of random numbers
from a given distribution? Something like rnorm just for non
normal distributions???
Thanks a lot!
Anna
SUppose we give your distribution the name Dist.
The generic approach
On 01/04/11 08:50, Ted Harding wrote:
On 31-Mar-11 19:23:33, Anna Lee wrote:
Hey List,
does anyone know how I can generate a vector of random numbers
from a given distribution? Something like rnorm just for non
normal distributions???
Thanks a lot!
Anna
SUppose we give your distribution the
Great. It is more clearer for me. Thanks all.
2010/8/24 Michael Dewey m...@aghmed.fsnet.co.uk
At 02:40 24/08/2010, rusers.sh wrote:
Hi all,
rmvnorm()can be used to generate the random numbers from a multivariate
normal distribution with specified means and covariance matrix, but i want
to
BTW, can you recommend a book on statistical simulations? I want to know
more on how to generate random numbers from distributions, how to generate
the theoretical models,...
Thanks a lot.
2010/8/24 Michael Dewey m...@aghmed.fsnet.co.uk
At 02:40 24/08/2010, rusers.sh wrote:
Hi all,
rusers.sh rusers.sh at gmail.com writes:
rmvnorm()can be used to generate the random numbers from a multivariate
normal distribution with specified means and covariance matrix, but i want
to specify the correlation matrix instead of covariance matrix for the
multivariate
normal
Hi,
If you see the link http://www.stata.com/help.cgi?drawnorm, and you can
see an example,
#draw a sample of 1000 observations from a bivariate standard
normal distribution, with correlation 0.5.
#drawnorm x y, n(1000) corr(0.5)
This is what Stata software did. What i hope to do in R should be
On Aug 23, 2010, at 11:05 PM, rusers.sh wrote:
Hi,
If you see the link http://www.stata.com/help.cgi?drawnorm, and you
can
see an example,
#draw a sample of 1000 observations from a bivariate standard
normal distribution, with correlation 0.5.
#drawnorm x y, n(1000) corr(0.5)
This is what
Hi Jane:
On Mon, Aug 23, 2010 at 8:05 PM, rusers.sh rusers...@gmail.com wrote:
Hi,
If you see the link http://www.stata.com/help.cgi?drawnorm, and you can
see an example,
#draw a sample of 1000 observations from a bivariate standard
normal distribution, with correlation 0.5.
#drawnorm x
At 05:06 PM 3/26/2008, Ted Harding wrote:
On 26-Mar-08 21:26:59, Ala' Jaouni wrote:
X1,X2,X3,X4 should have independent distributions. They should be
between 0 and 1 and all add up to 1. Is this still possible with
Robert's method?
Thanks
I don't think so. A whileago you wrote
The
Hi all
One suggestion, tranforme the x
0x11 Tranforme x1=exp(u1)/(exp(u1)+exp(u2)+exp(u3)+1)
0x21 Tranforme x2=exp(u2)/(exp(u1)+exp(u2)+exp(u3)+1)
0x31 Tranforme x3=exp(u3)/(exp(u1)+exp(u2)+exp(u3)+1)
0x41 Tranforme x4= 1/(exp(u1)+exp(u2)+exp(u3)+1)
x1+x2+x3+x4=1
Now
On Thu, 27 Mar 2008, Robert A LaBudde wrote:
At 05:06 PM 3/26/2008, Ted Harding wrote:
On 26-Mar-08 21:26:59, Ala' Jaouni wrote:
X1,X2,X3,X4 should have independent distributions. They should be
between 0 and 1 and all add up to 1. Is this still possible with
Robert's method?
Thanks
I
You have 4 random variables that satisfy 2 linear constraints, so you
are trying to generate a point in a (4-2) = 2 dimensional linear
(affine, in fact) subspace of R^4.
If you don't have any further requirement for the distribution of the
random points you want to generate, there are
On Wed, Mar 26, 2008 at 7:27 PM, Ala' Jaouni [EMAIL PROTECTED] wrote:
I failed to mention that the X values have to be positive and between 0 and
1.
Use Robert's method, and to do his step 1, use runif (?runif) to get
random numbers from the uniform distribution between 0 and 1.
Paul
On 26-Mar-08 20:13:50, Robert A LaBudde wrote:
At 01:13 PM 3/26/2008, Ala' Jaouni wrote:
I am trying to generate a set of random numbers that fulfill
the following constraints:
X1 + X2 + X3 + X4 = 1
aX1 + bX2 + cX3 + dX4 = n
where a, b, c, d, and n are known.
Any function to do this?
1.
X1,X2,X3,X4 should have independent distributions. They should be
between 0 and 1 and all add up to 1. Is this still possible with
Robert's method?
Thanks
On Wed, Mar 26, 2008 at 12:52 PM, Ted Harding
[EMAIL PROTECTED] wrote:
On 26-Mar-08 20:13:50, Robert A LaBudde wrote:
At 01:13 PM
X1,X2,X3,X4 should have independent distributions. They should be
between 0 and 1 and all add up to 1. Is this still possible with
Robert's method?
Thanks
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read
Ala' Jaouni wrote:
I am trying to generate a set of random numbers that fulfill the
following constraints:
X1 + X2 + X3 + X4 = 1
aX1 + bX2 + cX3 + dX4 = n
where a, b, c, d, and n are known.
Any function to do this?
You must give more information.
How are those numbers
On 26-Mar-08 21:26:59, Ala' Jaouni wrote:
X1,X2,X3,X4 should have independent distributions. They should be
between 0 and 1 and all add up to 1. Is this still possible with
Robert's method?
Thanks
I don't think so. A whileago you wrote
The numbers should be uniformly distributed (but in the
OOPS! A mistake below. I should have written:
This raises a general question: Does anyone know of
an R function to sample uniformly in the interior
of a general (k-r)-dimensional simplex embedded in
k dimensions, with (k-r+1) given vertices?
On 26-Mar-08 22:06:54, Ted Harding wrote:
On
Ala' Jaouni ajaouni at gmail.com writes:
X1,X2,X3,X4 should have independent distributions. They should be
between 0 and 1 and all add up to 1. Is this still possible with
Robert's method?
NO.
If they add to 1 they are not independent.
As Ted remarked, the constraints define two
39 matches
Mail list logo