Open jenessalemon opened 8 years ago
I assumed that the professor was not walking in a straight line. I assumed that he was wondering aimlessly so you could simply use the functions you have for Q14. Do you have that one working?
I have 13 almost working (that is the hurdle function) but I skipped 14. I guess I better go back to 14.
Sorry - I corrected that typo. I meant 14 not 13 and 14
From: jenessalemon notifications@github.com<mailto:notifications@github.com> Reply-To: pearselab/r-intro-jenessalemon reply@reply.github.com<mailto:reply@reply.github.com> Date: Thursday, November 3, 2016 at 8:01 PM To: pearselab/r-intro-jenessalemon r-intro-jenessalemon@noreply.github.com<mailto:r-intro-jenessalemon@noreply.github.com> Cc: Paul Wolf paul.wolf@usu.edu<mailto:paul.wolf@usu.edu>, Mention mention@noreply.github.com<mailto:mention@noreply.github.com> Subject: Re: [pearselab/r-intro-jenessalemon] Delusional Wandering Faculty (#10)
I have 13 almost working (that is the hurdle function) but I skipped 14. I guess I better go back to 14.
You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/pearselab/r-intro-jenessalemon/issues/10#issuecomment-258326573, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ACrBAC1x5TxMofUiLCMMxc-2Xmw9VKHzks5q6pIKgaJpZM4KpHW8.
Ok here's my go at #14 '''In English first" start the function initialize a vector that counts up by a factor of 5 (not sure if the factor of 5 matters) create a for loop to loop through the vector 100 times draw random variables for lat and long (x and y coordinates) store these as points plot the points, somehow making lines between them?'''
OK - good start. Note this part of the question: "assuming they cover a random, Normally-distributed distance in latitude and longitude in each interval". I did not worry too much about the time interval. But I did decide to track lat and long. There are many ways to do this. you need to be able to plot the professor's position at each time interval. You also need a starting point. In your example, what are you storing in the vector?
I'm storing time intervals in my vector. Is that wrong? Should I be storing lat and long values? (Which I am generating with rnorm)
Good question. If you store the time intervals in your vector. How are you going to plot the position (lat and long)?
From: jenessalemon notifications@github.com<mailto:notifications@github.com> Reply-To: pearselab/r-intro-jenessalemon reply@reply.github.com<mailto:reply@reply.github.com> Date: Thursday, November 3, 2016 at 8:20 PM To: pearselab/r-intro-jenessalemon r-intro-jenessalemon@noreply.github.com<mailto:r-intro-jenessalemon@noreply.github.com> Cc: Paul Wolf paul.wolf@usu.edu<mailto:paul.wolf@usu.edu>, Mention mention@noreply.github.com<mailto:mention@noreply.github.com> Subject: Re: [pearselab/r-intro-jenessalemon] Delusional Wandering Faculty (#10)
I'm storing time intervals in my vector. Is that wrong? Should I be storing lat and long values? (Which I am generating with rnorm)
You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/pearselab/r-intro-jenessalemon/issues/10#issuecomment-258328810, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ACrBAHaG7hYhB3PVy6lCK2iJVXh4jj_qks5q6pZygaJpZM4KpHW8.
You're not. So I guess you have to store the coordinates, which is something I have never done before. I tried just storing a vector that looks like this: (and this code starts on line 330 of the commit I just did) timestep <- c(x=0, y=0) So that the wanderer would start at (0,0) and adding random variables to that 100 times. I actually did get a plot! But it has two points on it, rather than all of the points (which that part I may be able to fix). I am wondering if we are even supposed to use rnorm, because the results would be very different if we had a standard deviation of 1000 rather than 1.
Excellent point about the standard deviation. I decided to go with the default. I am guessing that the idea is to get the idea of designing the function. I think rnorm is the correct way. I'll take a look.
Interesting. You first calculate all the lats, then all the longs. I see no reason why that would not work. Although I think it might cause a slight problem later when you need to decide when the professor finds a cliff. But it can still be done. The only thing is your vector is a vector of vectors. So I think that might be a matrix, but I am really not sure. I just stored lat and long at each cycle in separate vectors (a single loop) and then plotted using the TWO vectors. I don;t know enough about vectors or plotting to advise.
Good idea, let me try it that way.
Since the question doesn't ask us to calculate any distance, only simulate the process, I don't feel like I need to try to draw lines between the points. Plotting the points should show his location at each read, which I would argue is a good simulation of what happening. So I feel like the commit I just pushed should work. However, it didn't plot any points!!! Hoping either you or Will will know why. I have to run to soccer now, but will pick this up first thing in the morning.
Almost. But instead of using a vector, you have a single variable that keeps getting replaced by lat and long each loop. Create two vectors as you did before for one. Then plot the two vectors. I am not even sure that your single vector approach was wrong.
Your code for 14 is good, and you're almost there!... Here are two things to consider:
for
loop. Do you really want to plot lots of times, or plot once at the end?...late <- 0
with lat <- numeric(time)
?...Your code for 14 is good, and you're almost there!... Here are two things to consider:
for
loop. Do you really want to plot lots of times, or plot once at the end?...late <- 0
with lat <- numeric(time)
?...Thanks that helped so much! It's working great. 1- I want to plot once at the end, so I needed to plot lat and long, not one iteration. 2- I just changed lat and long to vectors the same length as the input.
Great!
@Wolflab, I am still getting the hang of writing out the algorithms in English, but what do you think about this for lesson_2 #15? Am I oversimplifying it?
define the function while the professor is still on the mountain draw random distances when he falls off (reaches 5 mi) return the time
I am wondering if this poor professor is walking in a straight line, or if we need to take into account that he could be moving in any direction at all times?