File: qmc_plot_curse.py

package info (click to toggle)
scipy 1.17.0-1exp2
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 235,340 kB
  • sloc: cpp: 506,914; python: 357,038; ansic: 215,028; javascript: 89,566; fortran: 19,308; cs: 3,081; f90: 1,150; sh: 860; makefile: 519; pascal: 284; lisp: 134; xml: 56; perl: 51
file content (37 lines) | stat: -rw-r--r-- 770 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
"""Visualize the curse-of-dimensionality.

It presents a saturated design in 1, 2 and 3 dimensions for a
given discretization.
"""
import matplotlib.pyplot as plt
import numpy as np

disc = 10

x = np.linspace(0, 1, disc)
y = np.linspace(0, 1, disc)
z = np.linspace(0, 1, disc)

xx, yy, zz = np.meshgrid(x, y, z)

fig = plt.figure(figsize=(12, 4))
ax = fig.add_subplot(131)
ax.set_aspect('equal')
ax.scatter(xx, yy * 0)
ax.set_xlabel(r'$x_1$')
ax.get_yaxis().set_visible(False)

ax = fig.add_subplot(132)
ax.set_aspect('equal')
ax.scatter(xx, yy)
ax.set_xlabel(r'$x_1$')
ax.set_ylabel(r'$x_2$')

ax = fig.add_subplot(133, projection='3d')
ax.scatter(xx, yy, zz)
ax.set_xlabel(r'$x_1$')
ax.set_ylabel(r'$x_2$')
ax.set_zlabel(r'$x_3$')

plt.tight_layout(pad=2)
plt.show()