Week 6 Feb 8.pdf - Week 6 Feb 8 Wednesday 12:23 PM Random...

Info icon This preview shows pages 1–2. Sign up to view the full content.

runif(# of numbers, lower bound = 0, upper bound = 1) Random numbers actually repeat after a certain number of periods (pseudo-random) same "random" numbers will pop up if you set seed before running runif Set seed (set.seed) so you can reproduce results if needed sample(max number) creates line of mumbers 0- max in random order Random Numbers data + runif (# of data elements, -0.5, +0.5) Helps see points that may be overlapping on graph Jitter f <- function() { if(runif(1)<0.15) { print("u ded") } else if (runif(1) < 0.4) { print("u lucky") } else { print("zinger") } } Random numbers at work: position <- numeric(steps+1) position[i+1] <- position[i] + 1 if (runif(1) < 0.5) else position[i+1] <- position[i] - 1 for (i in 1:steps) { } position random_walk <- function (steps) { } "Random Walk" Exist only within a function, not console as a whole l s() allows you to see all defined variables in an environment rm(var) removes a variable print (abc) # refers to the global variable ’abc’ print (xyz) # refers to the local variable (argument) 'xyz'
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern