Re: [R] runif with condition

2012-01-11 Thread Duncan Murdoch
On 12-01-11 5:12 AM, peter dalgaard wrote: On Jan 10, 2012, at 18:11 , AlanM wrote: I have to disagree with what's been posted, but I think some very interesting points have been addressed. I'd like to add my two cents. Consider the pair {X, 1-X} where X is sampled from a uniform(0,1) distri

Re: [R] runif with condition

2012-01-11 Thread peter dalgaard
On Jan 10, 2012, at 18:11 , AlanM wrote: > I have to disagree with what's been posted, but I think some very interesting > points have been addressed. I'd like to add my two cents. > > Consider the pair {X, 1-X} where X is sampled from a uniform(0,1) > distribution. The quantity 1- X also co

Re: [R] runif with condition

2012-01-10 Thread Carl Witthoft
AlanM said, "Consider the pair {X, 1-X} where X is sampled from a uniform(0,1) distribution. The quantity 1- X also comes from a uniform(0,1) distribution and therefore is probabilistic and not deterministic. The sum of independent random variables is itself a random variable. If X1, X2 & X3 a

Re: [R] runif with condition

2012-01-10 Thread AlanM
I have to disagree with what's been posted, but I think some very interesting points have been addressed. I'd like to add my two cents. Consider the pair {X, 1-X} where X is sampled from a uniform(0,1) distribution. The quantity 1- X also comes from a uniform(0,1) distribution and therefore is

Re: [R] runif with condition

2012-01-09 Thread Rui Barradas
Hello, David is obviously right: David Winsemius wrote > > If the sample space is defined, for instance, > as the set of all positive integers whose sum is 100, then it might be > possible to say that one randomly drawn instance of such a 4-tuple > would be "4 random numbers". What I mea

Re: [R] runif with condition

2012-01-09 Thread Carl Witthoft
This question *screams* for the standard response: "What is the problem you are trying to solve?" I can think of two related problems off the top of my head. 1) Write a function which generates the four bridge hands from a well-shuffled deck. 2) Throw 100 pennies into a big "shaker" with fo

Re: [R] runif with condition

2012-01-09 Thread David Winsemius
On Jan 9, 2012, at 10:27 AM, David Winsemius wrote: On Jan 9, 2012, at 10:06 AM, arunkumar wrote: Hi I want to generate 4 random number which sum up to 100 always "Random" plus condition == "non-random" An offlist correspondent has disputed this and I can admit that I was perhaps t

Re: [R] runif with condition

2012-01-09 Thread Jorge I Velez
Try foo <- function(n){ x <- runif(n) x * 100 / sum(x) } foo(4) HTH, Jorge.- On Mon, Jan 9, 2012 at 10:06 AM, arunkumar <> wrote: > Hi > I want to generate 4 random number which sum up to 100 always > > Please help > > > - > Thanks in Advance >Arun > -- > View this message in

Re: [R] runif with condition

2012-01-09 Thread jim holtman
try this: > x <- matrix(runif(100), ncol = 4) > # now scale each row to add up to 100 > x.new <- t(apply(x, 1, function(.row) .row * 100 / sum(.row))) > > > x.new [,1] [,2] [,3] [,4] [1,] 25.868978 31.4867075 34.547444 8.0968705 [2,] 35.803781 28.3485728 27.177462 8

Re: [R] runif with condition

2012-01-09 Thread Duncan Murdoch
On 09/01/2012 10:27 AM, David Winsemius wrote: On Jan 9, 2012, at 10:06 AM, arunkumar wrote: > Hi > I want to generate 4 random number which sum up to 100 always "Random" plus condition == "non-random" Perhaps you want 3 "random" numbers conjoined to the difference of their sum and 100?

Re: [R] runif with condition

2012-01-09 Thread David Winsemius
On Jan 9, 2012, at 10:06 AM, arunkumar wrote: Hi I want to generate 4 random number which sum up to 100 always "Random" plus condition == "non-random" Perhaps you want 3 "random" numbers conjoined to the difference of their sum and 100? Or perhaps you want 4 "random" numbers multiplied

Re: [R] runif with condition

2012-01-09 Thread Sarah Goslee
On Mon, Jan 9, 2012 at 10:06 AM, arunkumar wrote: > Hi > I want to generate 4 random number which sum up to 100 always > > Please help This sounds like homework. But you might want to search rseek.org for information on random numbers, and to ponder the mysteries of addition and division. S

[R] runif with condition

2012-01-09 Thread arunkumar1111
Hi I want to generate 4 random number which sum up to 100 always Please help - Thanks in Advance Arun -- View this message in context: http://r.789695.n4.nabble.com/runif-with-condition-tp4278704p4278704.html Sent from the R help mailing list archive at Nabble.com.