Implementation

In mining, let $p$ be the probability that either a good or malignant node will hit the target, and let probability be $q$ in one second over which one gets more than once.
Let's consider the case where $q=\frac{1}{300}$.
You can set $p \to 0,n \to \infty$ with the total hashrate (the number of hash calculations per unit time) as $ n times / s $.
\[ \lim_{p \to 0,n /to /inf}q=1-(1-p)^n=\frac{1}{300} \] Also, in mining, the computer calculates a large amount of hash in one second, and the difficulty level of hash calculation increases so as to correspond to it, so it can be thought of as approximating $ p \ to 0, n \ to \ infty $ I will. here,
\[ q=\lim_{p \to 0} 1-(1-p)^\frac{1}{300p}=e^-/frac{1}{300}\approx \frac{1}{300} \] Considering the relation between p and n such that it becomes, from the definition of the number of eyepears $e$
Given the relationship between p and n such that it becomes, we can approximate a from the definition of Napier number $e$. This makes it possible to deal with $q$ without using the value of $p$ which is extremely small, which is hard to handle with computers. Also assume that the hash rates of good nodes and malicious nodes are $a,b $, respectively, and the probability of drawing around per second is $ \alpha, \beta $.
\[ \alpha = \lim_{p \to 0} 1-(1-p)^\frac{1}{300p}\times \frac{a}{a+b}=e^-/frac{1}{300}\times \frac{a}{a+b} \] \[ \beta = \lim_{p \to 0} 1-(1-p)^\frac{1}{300p}\times \frac{b}{a+b}=e^-/frac{1}{300}\times \frac{b}{a+b} \] It was able to be. Simulation is executed by repeating judgment by trial which is done with this probability every 5 millisecond using Javascript.

シミュレーション

それぞれに自然数を入力してください(合計が20以下になるようにしてください。)

善性ノード: 敵性ノード: