[Lign251] Quick 251 question

rlevy at ling.ucsd.edu rlevy at ling.ucsd.edu
Sun Oct 21 14:16:53 PDT 2007


Jacob Wieser wrote:
> Hi again Roger-
>
> Ok, now I'm getting really confused. Either R is messing with me, or I
just have no clue what I'm doing and it's working fine. I'm back working
on #2, trying to generate my random samples, and just working on little
parts of the code.
>
> I was trying to get the code down just for the random generation of a
sample size of N in the uniform distribution:
>
> x <-- runif(50,0,1)
> head(x)
> [1] -0.5744449 -0.2941504 -0.5556475 -0.6154128 -0.5265833 -0.3995238
>
> Why are my numbers negative here? Am I missing something about how this
function works?  Also,
> x <-- runif(50,-1,0)
>> head(x)
> [1] 0.09497246 0.05768563 0.58514369 0.60508940 0.58766855 0.95039392
>
> are the (-1,0) not the parameters for the min and max for our
distribution?

Hi Jacob,

The problem is that you need to use

  <-

as the assignment operator, not

  <--

which is being parsed as

  <- -

i.e., assign to -1 times whatever comes next :)

Does that clear up the old hist() problem too?

Roger

-- 

Roger Levy                      Email: rlevy at ucsd.edu
Assistant Professor             Phone: 858-534-7219
Department of Linguistics       Fax:   858-534-4789
UC San Diego                    Web:   http://ling.ucsd.edu/~rlevy







More information about the Lign251 mailing list