mirror of
https://github.com/apachecn/ailearning.git
synced 2026-04-26 03:22:58 +08:00
2020-10-19 21:08:55
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
|
||||
In [1]:
|
||||
|
||||
```
|
||||
```py
|
||||
import numpy as np
|
||||
|
||||
def sinc(x):
|
||||
@@ -20,27 +20,27 @@ def sinc(x):
|
||||
|
||||
In [2]:
|
||||
|
||||
```
|
||||
```py
|
||||
sinc(0.0)
|
||||
|
||||
```
|
||||
|
||||
Out[2]:
|
||||
|
||||
```
|
||||
```py
|
||||
1.0
|
||||
```
|
||||
|
||||
In [3]:
|
||||
|
||||
```
|
||||
```py
|
||||
sinc(3.0)
|
||||
|
||||
```
|
||||
|
||||
Out[3]:
|
||||
|
||||
```
|
||||
```py
|
||||
3.8981718325193755e-17
|
||||
```
|
||||
|
||||
@@ -48,13 +48,13 @@ Out[3]:
|
||||
|
||||
In [4]:
|
||||
|
||||
```
|
||||
```py
|
||||
x = np.array([1,2,3])
|
||||
sinc(x)
|
||||
|
||||
```
|
||||
|
||||
```
|
||||
```py
|
||||
---------------------------------------------------------------------------
|
||||
ValueError Traceback (most recent call last)
|
||||
<ipython-input-4-9d4f36f2aa7a> in <module>()
|
||||
@@ -75,7 +75,7 @@ ValueError: The truth value of an array with more than one element is ambiguous.
|
||||
|
||||
In [5]:
|
||||
|
||||
```
|
||||
```py
|
||||
vsinc = np.vectorize(sinc)
|
||||
vsinc(x)
|
||||
|
||||
@@ -83,7 +83,7 @@ vsinc(x)
|
||||
|
||||
Out[5]:
|
||||
|
||||
```
|
||||
```py
|
||||
array([ 3.89817183e-17, -3.89817183e-17, 3.89817183e-17])
|
||||
```
|
||||
|
||||
@@ -91,7 +91,7 @@ array([ 3.89817183e-17, -3.89817183e-17, 3.89817183e-17])
|
||||
|
||||
In [6]:
|
||||
|
||||
```
|
||||
```py
|
||||
import matplotlib.pyplot as plt
|
||||
%matplotlib inline
|
||||
|
||||
@@ -102,7 +102,7 @@ plt.plot(x, vsinc(x))
|
||||
|
||||
Out[6]:
|
||||
|
||||
```
|
||||
```py
|
||||
[<matplotlib.lines.Line2D at 0xa24e4e0>]
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user