Advertisement
Guest User

Untitled

a guest
Mar 14th, 2016
299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.50 KB | None | 0 0
  1. import math
  2. import numpy as np
  3. import matplotlib.pyplot as plt
  4.  
  5. def f(z):
  6.     if z <= 0:
  7.         return 0
  8.     elif z >= 1:
  9.         return 1
  10.     else:
  11.         return math.exp(-1/(z*z) + 1)
  12.  
  13. x = np.linspace(0.0, 1.0, 10)
  14. y = np.vectorize(f)(x)
  15.  
  16. print(np.vectorize(f)(x[1:10]))
  17. print(np.vectorize(f)(x))
  18.  
  19. # Вывод
  20. [  1.80485139e-35   4.36346225e-09   3.35462628e-04   1.72059504e-02
  21.    1.06458504e-01   2.86504797e-01   5.20450121e-01   7.66726596e-01
  22.    1.00000000e+00]
  23. [0 0 0 0 0 0 0 0 0 1]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement