I need create a vector z in numpy such that z[i] = 1/(1+i). Is there faster way to do it then in the code below?
import numpy as np
n = 10000
z = np.zeros(n)
for i in xrange(n):
z[i] = 1.0/(1 + i)
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Quickest way: