subject

Let's get into some looping. Sometimes it is nice to generate your own data. Now let's take our first stab at it. (a) Lets start simple by just making a counter. Write a loop that just prints the numbers 1 through 5. To do this, first define an object counter outside of the loop. Set it equal to zero. Inside the loop use the print() command. It will simply print whatever is inside the brackets.
(b) Now lets use that counter. Make a loop that creates a vector, where the first element is 1, second element is 2, ..., the fifth element is 5: [1 2 3 4 5] Stat by making a blank vector so that you can fill it. I always start with a vector full of weird number. For example you could use -999. That way, if something is wrong in your data, you will be able to pick it out right away. After you create this container, you will fill it in the loop.
(c) Lets create a vector of random numbers, all of which come from a normal distribution with a different mean. To do this, we will use the rnorm() command. Look up the help file for this command. The argument n tells it how many numbers to draw. The argument mean tells it what the mean of the distribution is. The argument sd tells it what the standard deviation of the distribution is. Make a vector where there are 5 elements. The first element should be drawn from a distri- bution with a mean of 3, the second from a distribution with a mean of 7, the third from a distribution with a mean of 4, the fourth from a distribution with a mean of 10, and the fifth from a distribution with a mean of 2. To do this you will need to specify a vector as your list in the for command.
(d) Now we're going to do something a bit more difficult. I want you to recreate the first 10 numbers in the Fibonacci sequence. To do this, you will again need to create a container vector. Then you will need to feed it the first two numbers in the sequence outside of the loop. Then, you will need to fill the rest of the sequence by using the loop. (Hint: You can create counters inside of the loop to help pick out elements that are already in the matrix)

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 09:30
You wanted to look up information about alzheimer's, but you were unsure if it was spelled "alsheimer's" or "alzheimer's." which advanced search strategy would be useful? a) a boolean search b) using a wild card in your search c) trying different search engines d) doing a search for "alsheimer's not alzheimer's" asap. ill give brainlist.
Answers: 1
question
Computers and Technology, 23.06.2019 10:20
Suppose there is a relation r(a, b, c) with a b+-tree index with search keys (a, b).1. what is the worst-case cost of finding records satisfying 10 < a < 50 using this index, in terms of the number of records n1, retrieved and the height h of the tree? 2. what is the worst-case cost of finding records satisfying 10 < a < 50 and 5 < b < 10 using this index, in terms of the number of records n2 that satisfy this selection, as well as n1 and h defined above? 3. under what conditions on n1 and n2, would the index be an efficient way of finding records satisfying the condition from part (2)?
Answers: 1
question
Computers and Technology, 23.06.2019 12:00
Which of these is a benefit of using objects in a powerpoint presentation? a. collaborators can create the external files while you create and edit the slide show. b. you can easily change the theme and design of the presentation. c. you can have older data in the source file while having up-to-date data in the presentation. d. collaborators can easily share the presentation.
Answers: 2
question
Computers and Technology, 23.06.2019 12:00
What does the level 1 topic in a word outline become in powerpoint? a. first-level bullet item b. slide title c. third-level bullet item d. second-level bullet item
Answers: 1
You know the right answer?
Let's get into some looping. Sometimes it is nice to generate your own data. Now let's take our firs...
Questions
question
History, 19.07.2019 02:30
Questions on the website: 13722363