Created
November 29, 2017 23:03
-
-
Save xhiroga/625a41f4b0c2ca9cbb071a21721773e6 to your computer and use it in GitHub Desktop.
黄金比のグラフを出力してくれるやつ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import matplotlib.pyplot as plt | |
import numpy as np | |
def main(): | |
n = 30 | |
fib_list = [] | |
rate_list = [] | |
for num in range(n): | |
if num <= 1: | |
fib_list.append(num) | |
rate_list.append(num) | |
else: | |
fib_list.append(fib_list[num-1] + fib_list[num-2]) | |
rate_list.append(fib_list[num] / fib_list[num-1]) | |
x = np.arange(0, n, 1) | |
plt.plot(x, rate_list) | |
plt.show() | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment