Working with vectors

Asked

Viewed 76 times

2

I need to generate a vector with 100 random number positions and see what the ratio of numbers 2 to every 10 vector positions, the first part I got, but not the rest, it helps?

import random as rd


v=[]

for i in range(0, 20):
    w=rd.randint(0, 3)
    v.append(w) 
  • Hi! Well, I have a question: is it on average every 10 positions or is it something absolute, as "from element 0 to 9 has 3 numbers 2; from element 10 to 19 has 7 numbers 2; etc"?

  • then @johnd you have to look at the following, the randint function it will always randomize the number every time it is called. then not always 0, 10 we will have the count of 3 numbers 2.

  • I don’t know if it will help you, but he has tried to do range (0, 100, 10) that there 10 he counts 10 out of 10 and then w = Rd.randint(0, 3). after ready to do v.Count(2) to see how many numbers two were generated in this range.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.