can you help me with array
Question:
I have a problem how to do array starting from 1,1/2,1/3,1/4,1/5,……,1/99,1/100 in Python
Answers:
You are probably looking for np.put:
a = np.zeros(100)
for i in range(100):
a.put(i, 1/(i+1))
Edit:
After changing the original question, the best answer now is:
a = 1.0 / np.linspace(1, 100, 100)
I have a problem how to do array starting from 1,1/2,1/3,1/4,1/5,……,1/99,1/100 in Python
You are probably looking for np.put:
a = np.zeros(100)
for i in range(100):
a.put(i, 1/(i+1))
Edit:
After changing the original question, the best answer now is:
a = 1.0 / np.linspace(1, 100, 100)