You can use the statements ``while( I < 523 || I > 535)'' instead.
It will work fine.
Guo-Hao Huang
--------------------------------------------------
From: "Hongwei Dong" <pdxdong at gmail.com>
Sent: Friday, November 27, 2009 10:59 AM
To: "R-help Forum" <r-help at r-project.org>
Subject: [R] set condition in R
Hi, R users,
I'm using while() in R to set a condition. My condition is: i<523 or
i>535.
How should I write this in R? I try "while (i<523 or i>535)" and
it does not
work. Thanks.
Garry
On Tue, Nov 10, 2009 at 11:26 AM, Hongwei Dong <pdxdong at gmail.com>
wrote:
> Exactly! Thanks, Duncan.
>
> Let me re-phrase me question like this:
>
> 1) X_i values are independent Gammas, with the shape 0.067 and scale 0.008
> 2) Min(X)=1 and Max(X)=85
> 3) SUM(X)=2000
> 4) Do I also have to define the number of draws? if yes, it could be 250.
>
> Based on these restrictions, I want to generate random draw. I'm
wondering
> how I can do this in R. Thanks.
>
> Garry
>
>
>
> On Tue, Nov 10, 2009 at 11:17 AM, Duncan Murdoch <murdoch at
stats.uwo.ca
> >wrote:
>
> > On 11/10/2009 1:25 PM, Hongwei Dong wrote:
> >
> >> Hi, Dear R users,
> >>
> >> I'm wondering if I can do Monte Carlo Simulation in R. My
problem is
> like
> >> this: I know variable X follows Gamma distribution with shape
parameter
> >> 0.067 and scale parameter 0.008. The sum of the X is 2000. I need
R
> >> help
> >> me
> >> to simulate a vector of X that satisfies both the probability
> distribution
> >> and the sum. Anyone has a clue to this? Much appreciated.
> >>
> >
> > Your requirements are slightly contradictory or incomplete.
Here's one
> way
> > to fully specify the problem:
> >
> > The X_i values are independent Gammas, with the given shape and scale.
> You
> > want to simulate from the joint distribution conditional on the event
> sum(X)
> > == 2000.
> >
> > Is that your problem? I don't know how to do the simulation, but
maybe
> > someone else does.
> >
> > Duncan Murdoch
> >
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org 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.
>
[[alternative HTML version deleted]]
______________________________________________
R-help at r-project.org 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.