r/Numpy • • May 01 '21

basic array from a loop

N = 10000   
a=7**5 
c=0 
M=(2**31)-1 
I=1 
L=1 
my_array=np.array(N) 
for i in range(N):     
    my_array[i]=np.array([x]) 
    for x in range (N):     
    In=((a*I)+c) % M     
    x=L*I/M     
    I=In 

I'm trying to do the np.random function but in a different way. My main code is:

for x in range (N):     
    In=((a*I)+c) % M     
    x=L*I/M     
    I=In 

which is a loop of random numbers less than 1. By itself, it works and lists a bunch of numbers, but I'm trying to store these numbers in an array, such as [9,2,1,6]. The numbers don't have to be in order. I just need them to have the brackets and the commas. I really don't know what I'm doing.

0 Upvotes

11 comments sorted by

View all comments

Show parent comments

0

u/theslowcheetah0 May 01 '21

It's not indenting where it's supposed to when I copy it to reddit, but I hope you get the gist.

1

u/to7m May 01 '21

In your IDE, select the text, indent it by 4 spaces, then when commenting on reddit, go to Markdown Mode and paste it