Skip to content

Instantly share code, notes, and snippets.

@asakayu
Last active August 15, 2022 07:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asakayu/e783cbe5aaa33c25bbc5575d991e2ad3 to your computer and use it in GitHub Desktop.
Save asakayu/e783cbe5aaa33c25bbc5575d991e2ad3 to your computer and use it in GitHub Desktop.
import numpy as np
# 共分散行列
# 身長 バスト    ウエスト   ヒップ    肩      足      体重
cov = np.array([
[25.3009, 0.063088785, 0.087173585, 0.095501117, 4.170708501, 14.37817704, 0.294065688],
[0.063088785, 0.004163135, 0.003628662, 0.002353277, 0.034573308, 0.027373251, 0.006175157],
[0.087173585, 0.003628662, 0.005121, 0.002843, 0.050031, 0.041155, 0.007291],
[0.095501117, 0.002353277, 0.002843, 0.002701, 0.0439, 0.035186, 0.005578],
[4.170708501, 0.034573308, 0.050031, 0.0439, 4.4521, 1.936558, 0.110692],
[14.37817704, 0.027373251, 0.041155, 0.035186, 1.936558, 12.1801, 0.13921],
[0.294065688, 0.006175157, 0.007291, 0.005578, 0.110692, 0.13921, 0.01494]
])
# 各項目の平均値
mu = np.array([158.46, 83.45, 62.8, 90.57, 39.23, 70.99, 51.35])
# 対数変換した後の平均値を入れるべき?
# mu = np.array([158.46, 4.422166082, 4.137394, 4.504773, 39.23, 70.99, 3.931195])
print( np.random.multivariate_normal(mu, cov, size=10) )
# →multivariate_normalで出てきた値をさらに指数変換する
# result
# [[157.17653868 83.52152686 62.82307351 90.5356509 37.4999695
# 67.84633902 51.32360976]
# [156.40902894 83.62107797 62.94272436 90.678572 38.84426543
# 64.91747625 51.55203028]
# [160.8320308 83.47769574 62.7833447 90.58030217 39.30731665
# 74.27452667 51.35459517]
# [163.09097556 83.38081934 62.81326899 90.57274512 42.05391359
# 74.87221416 51.36223029]
# [159.30544013 83.41298845 62.78960707 90.62564372 35.49619009
# 68.90771185 51.4218314 ]
# [168.4264203 83.4412245 62.79086057 90.58902808 40.03612539
# 75.78174051 51.33472428]
# [156.16951822 83.43898476 62.83653992 90.54572375 40.54825291
# 69.64772774 51.29420731]
# [166.2083519 83.51764631 62.8186502 90.54347489 39.66573045
# 76.32497089 51.35023325]
# [166.0839105 83.44015962 62.90650903 90.61517912 40.17319839
# 77.88834217 51.58731256]
# [158.87783237 83.3038592 62.70456824 90.52824499 34.72611335
# 69.38327928 51.20675053]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment