[R] runif with condition

Rui Barradas ruipbarradas at sapo.pt
Tue Jan 10 05:33:43 CET 2012


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 meant to suggest is that the sum- 
> to-100-constraint means that once a set of 3 numbers from the  
> appropriate sample space have been drawn, that the fourth is no longer  
> "random".
> David Winsemius, MD
> West Hartford, CT
> 
> ______________________________________________
> R-help@ mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 

If the sum of 'k' numbers, random or deterministic, is a known constant 'n',
then one of them is a deterministic function of the other k-1.

Jim's idea is just the use of a simple (and deterministic) function. Suppose 
that we have 'k'  values 'x'. We can use the simple function y[i] = m*x[i],
i=1,...,k,  to get sum(y) == n. Solve for 'm', the value is the one given by
Jim.

And the deterministic nature of one of the numbers 'y' was hidden, but

sum(y) == sum(m*x) == m*sum(x) == n <=> sum(x) == n/m <=> x[k] == n/m -
(x[1] + ... + x[k-1])

In statistics this, I believe,  states the existence of only k-1 free
parameters, not k.

(By the way, a sample space of integers is a good idea, use sample(100, 3),
or a discrete distribution, rdisc(3)).

Rui Barradas



--
View this message in context: http://r.789695.n4.nabble.com/runif-with-condition-tp4278704p4281103.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list