趣味の研究

趣味の数学を公開しています。初めての方はaboutをご覧ください。

Collatz conjecture: the histogram of stopping times

I derived the frequency distribution of stopping times T_s in the previous article.

The histgram of stopping times from 1 to 10^8 is shown in the following cite.

https://en.wikipedia.org/wiki/Collatz_conjecture#/media/File:CollatzStatistic100million.png

 

f:id:hobbymath:20171202234322p:plain

The formula of frequency distribution is 

H(T_s)\sim\frac{BX\sqrt{w(T_s)}}{s\sqrt{\pi A}(B^2-{w(T_s)}^2)}\frac{1}{T_s^{\frac{3}{2}}}\exp(T_s(-A\frac{(B-w(T_s))^2}{w(T_s)}+\eta))       eq(1)

The rsult is 

f:id:hobbymath:20171203080147p:plain

Here,

s=\frac{2}{\log(3)}

v=\frac{\log(\frac{4}{3})}{\log(3)}

X=s\log(N)

w(T_s)=\frac{1}{3+v}(2+\frac{X}{T_s})

 

A=\frac{9}{2}-\frac{3+v}{s}

B=\sqrt{\frac{2}{A}}

\eta=6-\frac{2}{s}-2AB

 

 

The python code is  


# -*- coding: utf-8 -*-
"""
Created on Thu Nov 9 21:29:36 2017

@author: HobbyMath
"""
import numpy as np
import matplotlib.pylab as plt

v = np.log(4 / 3.0) / (np.log(3))
scale = 2.0 / np.log(3.0)
A=4.5-(3+v)/scale
B = np.sqrt(2/A)


all_num = 10**8
X = scale * np.log(all_num)
T_s = np.arange(50, 550)

#T_s  independent
eta = 6 - 2 / scale - 2 * A * B
lam = v + 2 * A / (3 + v) + 2 / scale - 3
#T_S dependent
wT = 2 /(3+v) + X / ( (3 + v) * T_s)
y = T_s * (-A * (B - wT) **2 / wT + eta)
hist = B * X * np.sqrt(wT) / (scale * (B**2 - wT**2) * np.sqrt(np.pi * A)) * np.exp(y) / T_s**1.5

#Plot histogram of stopping times
plt.plot(T_s, hist )
plt.xlabel("stopping times")