[PYTHON] Is there a bias in the numbers that appear in the Fibonacci numbers?

at first

・ It is a little paper for one month of program history. ・ I am studying agriculture at university. ・ I am a sophomore in college.

About this article

I will honestly investigate whether the numbers appearing in the Fibonacci sequence are biased. Since it is a brute force attack, no mathematical basis is given. (Not given) By the way F_0=0 Let's consider the Fibonacci sequence of F_1 = 1.

About the program

I will look it up in my own program as well as studying the program. First I checked the number of digits

Number of digits in the Fibonacci sequence

As a result of investigation, it became as follows.

F_10 :2 digits
F_100 :21 digits
F_1000 :209 digits
F_10000 :20899 digits
F_100000 :208988 digits

It seems that the number of digits / n has converged. (It might be interesting to look it up) The program used to investigate below

def fibo(N):
    A=0
    B=1
    if N==0:
        return 0
    elif N==1:
        return 1
    for i in range(1,N+1):
        if i%2==0:
            A+=B
        else:
            B+=A
    if N%2==1:
        return B
    else:
        return A

N=int(input())
ans=str(fibo(N))
print(len(ans))

Counting the number of appearances of numbers

Let's investigate. Let [a, b, c, d, e, f, g, h, i, j] = [number of 0s, number of 1s, ..., number of 9s].

F_10 : [0, 0, 0, 0, 0, 2, 0, 0, 0, 0]
F_100 : [1, 3, 3, 1, 3, 3, 1, 2, 2, 2]
F_1000 : [20, 13, 21, 18, 21, 23, 26, 21, 20, 26]
F_10000 : [217, 199, 228, 254, 194, 202, 217, 198, 197, 184]
F_100000 : [2109, 2135, 2149, 2096, 2023, 2053, 2051, 2034, 2131, 2118]

There seems to be no variation. Click here for the program used

def check(N):
    M=str(N)
    cnt=[0]*10
    for i in range(10):
        cnt[i]+=M.count(str(i))
    return cnt

Well as it is.

Finally, let's count the numbers that appear from F_0 to F_n. Programs to use below

def fc(N):
    cnt=[1,0,0,0,0,0,0,0,0,0]
    if N==0:
        return cnt
    else:
        A=0#Even number
        B=1#Odd number
        for i in range(1,N+1):
            if i%2==0:
                A+=B
                X=check(A)
                for i in range(10):
                    cnt[i]+=X[i]
            else:
                B+=A
                X=check(B)
                for i in range(10):
                    cnt[i]+=X[i]
    return cnt

Confirmation that it matches for the time being. Display the numbers used from F_0 to F_10 and check with the human eye whether they are added properly

F_0 : [1, 0, 0, 0, 0, 0, 0, 0, 0, 0]
F_1 : [0, 1, 0, 0, 0, 0, 0, 0, 0, 0]
F_2 : [0, 1, 0, 0, 0, 0, 0, 0, 0, 0]
F_3 : [0, 0, 1, 0, 0, 0, 0, 0, 0, 0]
F_4 : [0, 0, 0, 1, 0, 0, 0, 0, 0, 0]
F_5 : [0, 0, 0, 0, 0, 1, 0, 0, 0, 0]
F_6 : [0, 0, 0, 0, 0, 0, 0, 0, 1, 0]
F_7 : [0, 1, 0, 1, 0, 0, 0, 0, 0, 0]
F_8 : [0, 1, 1, 0, 0, 0, 0, 0, 0, 0]
F_9 : [0, 0, 0, 1, 1, 0, 0, 0, 0, 0]
F_10 : [0, 0, 0, 0, 0, 2, 0, 0, 0, 0]
F_0 ~ F_10 : [1, 4, 2, 3, 1, 3, 0, 0, 1, 0]

That's right for the program. Was good.

Let's count. It became as follows.

F_0 ~ F_10 : [1, 4, 2, 3, 1, 3, 0, 0, 1, 0]
F_0 ~ F_100 : [108, 139, 107, 101, 113, 95, 96, 116, 93, 104]
F_0 ~ F_1000 : [10475, 10696, 10495, 10476, 10431, 10516, 10433, 10576, 10350, 10303]
F_0 ~ F_10000 : [1045480, 1048189, 1045589, 1046744, 1044979, 1044900, 1042460, 1045481, 1043942, 1044171]
F_0 ~ F_20000 : [4179559, 4186491, 4179239, 4183641, 4180815, 4181752, 4178221, 4176724, 4176043, 4180145]
F_0 ~ F_30000 : [9406594, 9413374, 9403056, 9411723, 9406486, 9407934, 9403646, 9398938, 9397857, 9402484]
F_0 ~ F_40000 : [16719279, 16734411, 16720978, 16726026, 16719794, 16722921, 16714455, 16713027, 16711426, 16717999]
F_0 ~ F_50000 : [26119402, 26143034, 26126777, 26131821, 26123096, 26127116, 26119314, 26118936, 26118561, 26119246]
F_0 ~ F_100000 : [The limits of my program]

I tried to fix it to%

F_0 ~ F_10 : [6.667, 26.667, 13.333, 20.0, 6.667, 20.0, 0.0, 0.0, 6.667, 0.0]
F_0 ~ F_100 :[10.075, 12.966, 9.981, 9.422, 10.541, 8.862, 8.955, 10.821, 8.675, 9.701]
F_0 ~ F_1000 : [10.0, 10.211, 10.019, 10.001, 9.958, 10.039, 9.96, 10.096, 9.881, 9.836]
F_0 ~ F_10000 : [10.003, 10.029, 10.004, 10.015, 9.998, 9.997, 9.974, 10.003, 9.988, 9.99]
F_0 ~ F_20000 : [9.998, 10.015, 9.998, 10.008, 10.001, 10.004, 9.995, 9.992, 9.99, 10.0]
F_0 ~ F_30000 :[10.001, 10.009, 9.998, 10.007, 10.001, 10.003, 9.998, 9.993, 9.992, 9.997]
F_0 ~ F_40000 : [10.0, 10.009, 10.001, 10.004, 10.0, 10.002, 9.997, 9.996, 9.995, 9.999]
F_0 ~ F_50000 :[9.998, 10.007, 10.001, 10.003, 9.999, 10.001, 9.998, 9.998, 9.998, 9.998]

Summary

There seems to be no bias. I would like to keep it as a memo if I do something in the practice of the program in the future> <

Recommended Posts

Is there a bias in the numbers that appear in the Fibonacci numbers?
Is there a special in scipy? ??
Is there a secret to the frequency of pi numbers?
Play a sound in Python assuming that the keyboard is a piano keyboard
Is there NaN in the pandas DataFrame?
Arrange the numbers in a spiral shape
Isn't there a default value in the dictionary?
A shell program that displays the Fibonacci sequence
Is there a contradiction between the party that protects the people from NHK and the party that protects NHK from the people?
Check if the string is a number in python
Linux is something like that in the first place
Find the part that is 575 from Wikipedia in Python
There is a pattern that the program did not stop when using Python threading
The Linux emulator "iSH" that runs on the iPad is a hot topic in me
When reading an image with SimpleITK, there is a problem if there is Japanese in the path
[Golang] A program that determines the turn with random numbers
The image is a slug
I wrote a script that splits the image in two
Python will fail if there is a space after the backslash
To make sure that the specified key is in the specified bucket in Boto 3
Unfortunately there is no sense of unity in the where method
I made a program that solves the spot the difference in seconds
Anyway, the fastest serial communication log is left in a file
Delete a particular character in Python if it is the last
How to judge that the cross key is input in Python3
A timer (ticker) that can be used in the field (can be used anywhere)
A function that measures the processing time of a method in python
The story that inheritance behavior is quite different in each language
What's new in datetime that is a bit more useful in Python 3
[Golang] Check if a specific character string is included in the character string
A programming language that young people will need in the future
There is no switch in python
[Python] Whiten the parts that turn black when there is no data in the Choropleth map of Folium.
Check if there is a specific symbol in the executable file and its dependent libraries (simplified version)
What to do if there is a decimal in python json .dumps
Note that the Google Maps Android API GoogleMap.getProjection is not a singleton
Is the space replaced by a plus sign or% 20 in percent-encoding processing?
DJango memo: From the beginning (editing the management screen) There is a mystery
Estimate the probability that a coin will appear on the table using MCMC
I want to identify the alert email. --Is that x a wildcard? ---
The eval () function that calculates a string as an expression in python
What is a C language library? What is the information that is open to the public?
What is the fastest way to create a reverse dictionary in python?
A class that hits the DMM API
Cut out A4 print in the image
Run the Python interpreter in a script
What is "mahjong" in the Python library? ??
Hash in Perl is a dictionary in Python
[python] [meta] Is the type of python a type?
A code that corrects the yoon / sokuon (sokuon)
Project Euler # 2 "Even Fibonacci Numbers" in Python
[Python] A program that rounds the score
There is no telnet! At that time
The date is displayed incorrectly in matplotlib.
A solution to the problem that the Python version in Conda cannot be changed
Find a building on Google Earth that is the same height as Shingodzilla
Create a BOT that displays the number of infected people in the new corona
[Django] Create a form that automatically fills in the address from the zip code
Let's display a simple template that is ideal for Django for the first time
[Python] A program that calculates the difference between the total numbers on the diagonal line.
Correspondence of the event that the result of form.is_valid () is always False in Django2 system