2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

正規分布で時計を作ってみた

2
Last updated at Posted at 2019-10-22

百聞は一見に如かずという事で。

20時49分です。

norm.png

形状と時刻が一対一対応しているのでアナログ時計と同じように使えます。

作り方

python
import numpy as np
import matplotlib.pyplot as plt
from datetime import datetime as dt
from scipy.stats import norm

# 現在時刻を取得
hour = dt.now().hour
minute = dt.now().minute

# 標準偏差は正にしたいので
# あと、[平均]時 [標準偏差]分 形式にしたいので
if minute == 0:
    minute = 60
    
# x軸の左右端
xlim = 200

# 値を作成
X = np.arange(-1*xlim, xlim, 0.1)
Y = norm.pdf(X, hour, minute)

# プロット
plt.plot(X,Y)
plt.title('μ: %d    σ: %d' % (hour, minute), fontsize=14)
plt.xlim([-1*xlim, xlim])
plt.rcParams["font.size"] = 14
plt.savefig('norm.png')
plt.show()
2
0
0

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
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?