0
0

二次元標準正規分布を3Dプロットする

Posted at

二次元標準正規分布を3Dプロットしたい

image.png

プロットしました。

import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

# 二次元標準正規分布の定義
def normal_distribution_2d(x, y):
    return 1 / (2 * np.pi) * np.exp(-0.5 * (x**2 + y**2))

# X, Y の値の生成
x = np.linspace(-5, 5, 100)
y = np.linspace(-5, 5, 100)
X, Y = np.meshgrid(x, y)

# Z の値(分布の計算)
Z = normal_distribution_2d(X, Y)

# 3D プロット
fig = plt.figure(figsize=(8, 6))
ax = fig.add_subplot(111, projection='3d')
ax.plot_surface(X, Y, Z, cmap='viridis')

ax.set_xlabel('X axis')
ax.set_ylabel('Y axis')
ax.set_zlabel('Probability Density')
ax.set_title('2D Standard Normal Distribution')

plt.show()

image.png

0
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0