solutions update from 7ed0c61
This commit is contained in:
committed by
github-actions[bot]
parent
7ed0c61ccd
commit
6cedcb2ad9
File diff suppressed because it is too large
Load Diff
@@ -566,9 +566,17 @@ for index in np.ndindex(Z.shape):
|
||||
|
||||
```python
|
||||
X, Y = np.meshgrid(np.linspace(-1, 1, 10), np.linspace(-1, 1, 10))
|
||||
D = np.sqrt(X*X+Y*Y)
|
||||
sigma, mu = 1.0, 0.0
|
||||
G = np.exp(-( (D-mu)**2 / ( 2.0 * sigma**2 ) ) )
|
||||
G = np.exp(-((X - mu) ** 2 + (Y - mu) ** 2) / (2.0 * sigma**2))
|
||||
print(G)
|
||||
|
||||
# Another solution using the fact that a 2D Gaussian is separable
|
||||
# Author: Nin17
|
||||
x = np.linspace(-1, 1, 10)
|
||||
y = np.linspace(-1, 1, 10)
|
||||
gx = np.exp(-((x - mu) ** 2 / (2.0 * sigma**2)))
|
||||
gy = np.exp(-((y - mu) ** 2 / (2.0 * sigma**2)))
|
||||
G = gy[:, None] * gx[None, :]
|
||||
print(G)
|
||||
```
|
||||
#### 57. How to randomly place p elements in a 2D array? (★★☆)
|
||||
|
||||
@@ -566,9 +566,17 @@ for index in np.ndindex(Z.shape):
|
||||
|
||||
```python
|
||||
X, Y = np.meshgrid(np.linspace(-1, 1, 10), np.linspace(-1, 1, 10))
|
||||
D = np.sqrt(X*X+Y*Y)
|
||||
sigma, mu = 1.0, 0.0
|
||||
G = np.exp(-( (D-mu)**2 / ( 2.0 * sigma**2 ) ) )
|
||||
G = np.exp(-((X - mu) ** 2 + (Y - mu) ** 2) / (2.0 * sigma**2))
|
||||
print(G)
|
||||
|
||||
# Another solution using the fact that a 2D Gaussian is separable
|
||||
# Author: Nin17
|
||||
x = np.linspace(-1, 1, 10)
|
||||
y = np.linspace(-1, 1, 10)
|
||||
gx = np.exp(-((x - mu) ** 2 / (2.0 * sigma**2)))
|
||||
gy = np.exp(-((y - mu) ** 2 / (2.0 * sigma**2)))
|
||||
G = gy[:, None] * gx[None, :]
|
||||
print(G)
|
||||
```
|
||||
#### 57. How to randomly place p elements in a 2D array? (★★☆)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "a3747e86",
|
||||
"id": "94b10be0",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# 100 numpy exercises\n",
|
||||
@@ -18,7 +18,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "8b9ef9a4",
|
||||
"id": "1d0b9900",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"File automatically generated. See the documentation to update questions/answers/hints programmatically."
|
||||
@@ -26,7 +26,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "792c1217",
|
||||
"id": "21313ae9",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Run the `initialise.py` module, then call a random question with `pick()` an hint towards its solution with\n",
|
||||
@@ -36,7 +36,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "541f746c",
|
||||
"id": "c4ad3a14",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -46,7 +46,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "d1743adb",
|
||||
"id": "13bdf6d0",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
|
||||
Reference in New Issue
Block a user