Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions task1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import numpy as np
import matplotlib.pyplot as plt

a = np.random.random((1,500))

x = np.arange(0.1,100,.1)
y = (1/0.001)* np.log(x)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You were supposed to plot the y values for a, rather than taking x. This is fine too!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use a function for (1/0.001)* np.log(x).


#print(y)
#print(a)
plt.plot(x,y)
plt.show()
15 changes: 15 additions & 0 deletions task2a.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import numpy as np
import matplotlib.pyplot as plt
import time

start1_time = time.time()

x = np.random.rand(10)
y = np.random.rand(10)

#print(x)
#print(y)

print(x.dot(y))
print("--- %s seconds ---" % (time.time() - start1_time))

17 changes: 17 additions & 0 deletions task2b.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import numpy as np
import matplotlib.pyplot as plt
import time

start2_time = time.time()

x = np.random.rand(10)
y = np.random.rand(10)

sum = 0
i=0
for a in x:
sum = sum + (x[i]*y[i])
i=i+1
Copy link
Collaborator

@deepakgouda deepakgouda May 26, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should write the loop something like this:

for i in range(len(x)):
    sum = sum + x[i]*y[i]

print(sum)

print("--- %s seconds ---" % (time.time() - start2_time))