Pages:
Author

Topic: [Quiz] Answer the Bitcoin question and earn merits! #2 (Read 1031 times)

legendary
Activity: 3290
Merit: 16489
Thick-Skinned Gang Leader and Golden Feather 2021
jr. member
Activity: 15
Merit: 0
Edited out.
legendary
Activity: 1512
Merit: 7340
Farewell, Leo
member
Activity: 108
Merit: 39
Mia Chloe is right. Mining is a Poisson process. One important characteristic of a Poisson process, is that it is memoryless; whether a block was found recently or not, does not give us a clue about the likelihood that another block will be found soon. Whether the last block was mined 2 hours ago or 10 minutes ago, the probability of mining a block within the next 10 minutes remains the same. (Of course, under the assumption that hashrate is constant and blocks are mined every 10 minutes on average)

As displayed in Wikipedia, the formula is: P{N = n} = Λn * e / n!, where:
- n: the number of blocks to find within 10 minutes
- Λ: the number of blocks you would expect to find in 10 minutes.

For n=3, Λ=1, we get 0.0613132, or 6.13%.

The C++ code that implements it is the following:
Code:
#include
#include
using namespace std;

// constant number 'e'
const double Euler = std::exp(1.0);

// return x^y
int power(int x, int y){
    if(y == 0 && x != 0) return 1;
    int i, z = x;  
    for(i = 0; i < y; i++)
        z *= z;

    return z;
}

// factorial of integer x
int fact(int x){
    if(x == 0) return 1;
    
    int i, factorial = 1;
    for(i = 1; i <= x; i++)
        factorial *= i;

    return factorial;
}

int main(){
    // P{N = n} = Λ^n * e^-Λ / n!
    // n: number of blocks to find within given time frame
    // Λ or lambda: number of blocks you would expect to find in 10 minutes

    int n = 3, lambda = 1;
    double P = power(lambda, n) * pow(Euler, -lambda) / fact(n);
    
    cout << P << endl;
}

Just compile with "g++ -o mining mining.cpp" and run with "./mining".

See how abruptly improbable it becomes as you increase n.
Code:
For n=3, Λ=1, P=0.0613132
For n=4, Λ=1, P=0.01532830
For n=5, Λ=1, P=0.00306566
For n=6, Λ=1, P=0.000510944
For n=7, Λ=1, P=0.00000729
Hahaha, I wasn't expecting to win against top members in the forum but I thought I was pretty close even though my presentation wasn't good enough. Thumbs up @Mia Chloe you deserve the win. @BlackHatcoiner hoping to participate again in your next contest.
sr. member
Activity: 700
Merit: 470
Hope Jeremiah 17vs7
So in the end the exactly didn't matter and I guessed this was why after this:

Pr (3 block) = 1 - (Pr( ≤2 block) + Pr (>3 block))
I still got the same 0.06133 which is roughly same as the 0.06131
But you're calculating exactly three in here. If P(block=3) = 1 - {every other possibility than P(block=3)), then you're calculating for exactly three. If you wanted to calculate for at least three, you would work out P(block >= 3), which is just 1 - P(block = 0) - P(block = 1) - P(block = 2) = 0.080302 ~= 8%.
 
I was actually working base on this
Question: What is the chance of having exactly three blocks mined within the next 10 minutes? You can assume that a new block is mined every 10 minutes on average.

I wanted to check reality to see how often this occurred (start with Bitcoin block data available in CSV format, and download time.txt), but there is no accurate data on block times. In some cases the block time moves backwards.
That will be a little difficult. Block times are not accurate, as rightly said. Your best source of information is debug.log (in which it is written when your node received the blocks). But it won't be accurate either, because hashrate does not remain constant for a long time.
franky1 said this earlier on this thread
legendary
Activity: 1512
Merit: 7340
Farewell, Leo
So in the end the exactly didn't matter and I guessed this was why after this:

Pr (3 block) = 1 - (Pr( ≤2 block) + Pr (>3 block))
I still got the same 0.06133 which is roughly same as the 0.06131
But you're calculating exactly three in here. If P(block=3) = 1 - {every other possibility than P(block=3)), then you're calculating for exactly three. If you wanted to calculate for at least three, you would work out P(block >= 3), which is just 1 - P(block = 0) - P(block = 1) - P(block = 2) = 0.080302 ~= 8%.

Another fun fact. The probability of not finding any block for 10 minutes is the same as finding exactly one block; about 36.8%.

I wanted to check reality to see how often this occurred (start with Bitcoin block data available in CSV format, and download time.txt), but there is no accurate data on block times. In some cases the block time moves backwards.
That will be a little difficult. Block times are not accurate, as rightly said. Your best source of information is debug.log (in which it is written when your node received the blocks). But it won't be accurate either, because hashrate does not remain constant for a long time.
legendary
Activity: 3290
Merit: 16489
Thick-Skinned Gang Leader and Golden Feather 2021
6.13%.
I wanted to check reality to see how often this occurred (start with Bitcoin block data available in CSV format, and download time.txt), but there is no accurate data on block times. In some cases the block time moves backwards.
sr. member
Activity: 700
Merit: 470
Hope Jeremiah 17vs7
-snip-
So in the end the exactly didn't matter and I guessed this was why after this:

Pr (3 block) = 1 - (Pr( ≤2 block) + Pr (>3 block))
I still got the same 0.06133 which is roughly same as the 0.06131

My python code, works in similar way as your c++
I wrote mine as a code in python, to be Frank my code is not professional i`m still working on that

Code:
import math
Parameter = 1
RandomNumber = 3
EulerNumber = 2.71828

Probability = (Parameter ** RandomNumber ) * (EulerNumber ** (-Parameter)) / math.factorial(RandomNumber)
RoundedProbability = round(Probability, 4)
Inpercentage = str(RoundedProbability * 100)
print ('The chance of having exactly three blocks mined within the next 10 minutes = ',
       RoundedProbability, 'or', Inpercentage + '%')


Poisson distribution was also spoken about on the bitcoin whitepaper in page 7 even in regards to your previous question
I did edit a part which was, math.factorial(3) to math.factorial(RandomNumber)
member
Activity: 224
Merit: 42
Mia Chloe is right. Mining is a Poisson process. One important characteristic of a Poisson process, is that it is memoryless; whether a block was found recently or not, does not give us a clue about the likelihood that another block will be found soon. Whether the last block was mined 2 hours ago or 10 minutes ago, the probability of mining a block within the next 10 minutes remains the same. (Of course, under the assumption that hashrate is constant and blocks are mined every 10 minutes on average)

As displayed in Wikipedia, the formula is: P{N = n} = Λn * e / n!, where:
- n: the number of blocks to find within 10 minutes
- Λ: the number of blocks you would expect to find in 10 minutes.

For n=3, Λ=1, we get 0.0613132, or 6.13%.

The C++ code that implements it is the following:
Code:
#include
#include
using namespace std;

// constant number 'e'
const double Euler = std::exp(1.0);

// return x^y
int power(int x, int y){
    int i, z = x;   
    for(i = 0; i < y; i++)
        z *= z;

    return z;
}

// factorial of integer x
int fact(int x){
    if(x == 0) return 1;
   
    int i, factorial = 1;
    for(i = 1; i <= x; i++)
        factorial *= i;

    return factorial;
}

int main(){
    // P{N = n} = Λ^n * e^-Λ / n!
    // n: number of blocks to find within given time frame
    // Λ or lambda: number of blocks you would expect to find in 10 minutes

    int n = 3, lambda = 1;
    double P = power(lambda, n) * pow(Euler, -lambda) / fact(n);
   
    cout << P << endl;
}

Just compile with "g++ -o mining mining.cpp" and run with "./mining".

See how abruptly improbable it becomes as you increase n.
Code:
For n=3, Λ=1, P=0.0613132
For n=4, Λ=1, P=0.01532830
For n=5, Λ=1, P=0.00306566
For n=6, Λ=1, P=0.000510944
For n=7, Λ=1, P=0.00000729

 The number of blocks expected to be found in a certain time follows the poisson distribution .
Which means the probability of finding exactly K block in T minutes is represented by the formula;
  P(K,T)=(T/10)^K * e‐T/10/K!

Where; T=Time(mins) , K= Block
Inputting the values:

 P(3,10) =      (10/10)^3    *   e‐(10/10)/3!
               =      1³ * e‐¹/3!
               =      0.0613.

For simplicity sake;

               =      0.367879÷6
               =     0.0613.
          %  =     6.13%
full member
Activity: 208
Merit: 125
Betunlim|Welcome Bonus 100%|Upto 1000€
Mia Chloe is right. Mining is a Poisson process. One important characteristic of a Poisson process, is that it is memoryless; whether a block was found recently or not, does not give us a clue about the likelihood that another block will be found soon. Whether the last block was mined 2 hours ago or 10 minutes ago, the probability of mining a block within the next 10 minutes remains the same. (Of course, under the assumption that hashrate is constant and blocks are mined every 10 minutes on average)

As displayed in Wikipedia, the formula is: P{N = n} = Λn * e / n!, where:
- n: the number of blocks to find within 10 minutes
- Λ: the number of blocks you would expect to find in 10 minutes.

For n=3, Λ=1, we get 0.0613132, or 6.13%.

The C++ code that implements it is the following:
Code:
#include
#include
using namespace std;

// constant number 'e'
const double Euler = std::exp(1.0);

// return x^y
int power(int x, int y){
    int i, z = x;   
    for(i = 0; i < y; i++)
        z *= z;

    return z;
}

// factorial of integer x
int fact(int x){
    if(x == 0) return 1;
   
    int i, factorial = 1;
    for(i = 1; i <= x; i++)
        factorial *= i;

    return factorial;
}

int main(){
    // P{N = n} = Λ^n * e^-Λ / n!
    // n: number of blocks to find within given time frame
    // Λ or lambda: number of blocks you would expect to find in 10 minutes

    int n = 3, lambda = 1;
    double P = power(lambda, n) * pow(Euler, -lambda) / fact(n);
   
    cout << P << endl;
}

Just compile with "g++ -o mining mining.cpp" and run with "./mining".

See how abruptly improbable it becomes as you increase n.
Code:
For n=3, Λ=1, P=0.0613132
For n=4, Λ=1, P=0.01532830
For n=5, Λ=1, P=0.00306566
For n=6, Λ=1, P=0.000510944
For n=7, Λ=1, P=0.00000729

I got the same answer on the below link?:

https://bitcointalksearch.org/topic/m.63832047
member
Activity: 84
Merit: 57
For example, to find the chance of moving exactly three blocks in the next 10 minutes, we can use the Poisson distribution, which shows the fewest events in a given time.

Because of this, the chance of mining exactly three blocks in the next 10 minutes is about 0.06132, or 6.132%.


The C++ code that implements it is the following:
Code:
#include
#include
using namespace std;

// constant number 'e'
const double Euler = std::exp(1.0);

// return x^y
int power(int x, int y){
    int i, z = x;  
    for(i = 0; i < y; i++)
        z *= z;

    return z;
}

// factorial of integer x
int fact(int x){
    if(x == 0) return 1;
    
    int i, factorial = 1;
    for(i = 1; i <= x; i++)
        factorial *= i;

    return factorial;
}

int main(){
    // P{N = n} = Λ^n * e^-Λ / n!
    // n: number of blocks to find within given time frame
    // Λ or lambda: number of blocks you would expect to find in 10 minutes

    int n = 3, lambda = 1;
    double P = power(lambda, n) * pow(Euler, -lambda) / fact(n);
    
    cout << P << endl;
}
We get 0.0613132, or 6.13%.
Yes bro correct C++ is coming to me same.
legendary
Activity: 1512
Merit: 7340
Farewell, Leo
Mia Chloe is right. Mining is a Poisson process. One important characteristic of a Poisson process, is that it is memoryless; whether a block was found recently or not, does not give us a clue about the likelihood that another block will be found soon. Whether the last block was mined 2 hours ago or 10 minutes ago, the probability of mining a block within the next 10 minutes remains the same. (Of course, under the assumption that hashrate is constant and blocks are mined every 10 minutes on average)

As displayed in Wikipedia, the formula is: P{N = n} = Λn * e / n!, where:
- n: the number of blocks to find within 10 minutes
- Λ: the number of blocks you would expect to find in 10 minutes.

For n=3, Λ=1, we get 0.0613132, or 6.13%.

The C++ code that implements it is the following:
Code:
#include
#include
using namespace std;

// constant number 'e'
const double Euler = std::exp(1.0);

// return x^y
int power(int x, int y){
    if(y == 0 && x != 0) return 1;
    int i, z = x;  
    for(i = 0; i < y; i++)
        z *= z;

    return z;
}

// factorial of integer x
int fact(int x){
    if(x == 0) return 1;
    
    int i, factorial = 1;
    for(i = 1; i <= x; i++)
        factorial *= i;

    return factorial;
}

int main(){
    // P{N = n} = Λ^n * e^-Λ / n!
    // n: number of blocks to find within given time frame
    // Λ or lambda: number of blocks you would expect to find in 10 minutes

    int n = 3, lambda = 1;
    double P = power(lambda, n) * pow(Euler, -lambda) / fact(n);
    
    cout << P << endl;
}

Just compile with "g++ -o mining mining.cpp" and run with "./mining".

See how abruptly improbable it becomes as you increase n.
Code:
For n=3, Λ=1, P=0.0613132
For n=4, Λ=1, P=0.01532830
For n=5, Λ=1, P=0.00306566
For n=6, Λ=1, P=0.000510944
For n=7, Λ=1, P=0.00000729
newbie
Activity: 1
Merit: 0

Short introduction for anyone who missed the first quiz:
I decided to start these forum quiz-series, where I'll be asking questions of educational character, to improve the average user's knowledge around Bitcoin. The questions will mostly be technical and historical. To create an incentive, I will generously merit the first person who replies with the correct answer. If that is not good enough incentive, I'll create a leaderboard!

  • Your answer needs to be explanatory. Not just a yes-no or a single number.
  • If nobody finds the answer until the cut-off date, I will submit it.
  • Have fun! It's a game.  Smiley

The first question was a tribute to the whitepaper. Now let's see how good we are at math.



Question: What is the chance of having exactly three blocks mined within the next 10 minutes? You can assume that a new block is mined every 10 minutes on average.

Cut-off date: 27/03/2024.

Unfortunately, we can't calculate the exact chance of having exactly three blocks mined within the next 10 minutes with the given information. Here's why:
Block mining is not deterministic: While the average block time might be 10 minutes, it's not guaranteed. The actual time between blocks can vary due to factors like mining difficulty.
Poisson distribution, not binomial: Since new blocks are independent events (one block doesn't affect the next), a Poisson distribution would be more appropriate for this scenario. This model considers the average rate of events (blocks mined) within a specific timeframe (10 minutes).
However, we can explore the likelihood of having around three blocks mined in 10 minutes using the Poisson distribution.
Here's what we'd need:
Average block time: We're given that it's 10 minutes on average.
With this information, we can calculate the lambda (λ) parameter for the Poisson distribution, which represents the average number of events (blocks mined) expected in a given timeframe (10 minutes).
λ = average rate (blocks/minute) * time (minutes)
λ = 1 block / 10 minutes * 10 minutes
λ = 1
Using a Poisson probability calculator or statistical software, we can then estimate the probability of getting exactly 3 blocks (k = 3) within 10 minutes (λ = 1)
This will give you a probability value, but it won't be an exact chance due to the inherent randomness of block mining times.
sr. member
Activity: 476
Merit: 299
Learning never stops!
Giving this a try :

1.566E-14
sr. member
Activity: 700
Merit: 470
Hope Jeremiah 17vs7


Using this formula I got 0
Where :
Random number (K) = 3
Time interval (t)= 10
Parameter Rate(a) = 10
e = 2.71828
The formula is correct, I have seen my error :
Random number (K) = 3
Time interval (t)= 10
Parameter Rate(a) = 1/10 =0.1
e = 2.71828
 Probability of 3 blocks mined in an average of 10 minutes = 0.06132

My interpretation is if the exactly is :
With in the 10 minutes time interval
0 to infinite block can be mined while though my constrict is 3 block

Then
Pr (3 block) = 1 - (Pr( ≤2 block) + Pr (>3 block)
Where :
Pr( ≤2 block) = Pr (0 block) + Pr (1 block) + Pr (2 block)
 Pr (>3 block) = Pr (4 block) + Pr (5 block) + Pr (6 block)...
Though this tends to infinity but I stop in block 6 since I'm using 5 decimal place

But my final answer was Pr(3 block) = 0.06133 which is the similar to the Probability of 3 blocks mined in an average of 10 minutes = 0.06132




legendary
Activity: 4424
Merit: 4794
its worth noting.. someone done a study in ~2018 of the first 535k blocks
this is what they said
Quote
For "shortest", since timestamps are not strictly enforced and can be fudged accidentally or intentionally, it is possible for a block to have an earlier timestamp than its predecessor, by up to 2 hours (7200 seconds), in which case the time difference is negative. This has happened 13828 times. The most negative difference is −7125 seconds (1 hour 58 minutes 45 seconds) between blocks 156113 and 156114.

so dont use a blocks time stamp of blockchain history to gauge how often 3 blocks were solved in under 10 minutes.. timestamps are not accurate measure of actual time they were actually solved
member
Activity: 66
Merit: 5
Eloncoin.org - Mars, here we come!
Sir, the probability of having exactly 3 blocks mined within the next 10 minutes is approximately 0.0613, or 6.13%.
I'm learning alot here, but i believe this answer of yours is AI generated.

If you did it yourself then show working, or at least explain how you got the answer.

Here is one of the rules of the quiz, your answer must be explanatory.

  • Your answer needs to be explanatory. Not just a yes-no or a single number.
If you don't know the answer you can just remain calm and learn from what others will do probably try to use one of the formulas posted above to find your own answer you might be correct.
member
Activity: 108
Merit: 39


It seems newbies aren't allowed to send a picture here because I did my calculations in my notebook as it would have been easier for me to drop a picture of my calculations. I may be wrong though with my answer but am delighted to participate.
I would be glad to see your calculations! Drop them in talkimg and post them as a link (since you're prohibited to posting images).

here is my calculation, i hope you can see it clearly.
sr. member
Activity: 448
Merit: 560
Crypto Casino and Sportsbook


I tried computing the blocks mined within 10minutes which also includes that of 10 minutes and less meaning lambda would vary by a common difference of 0.1 by using 9,8,7...... Minutes.

More details in my solution above
member
Activity: 308
Merit: 32
A miner with the advantage of 51% attack will be able to
 1.double send coins and also
2. prevent confirmation of transactions,
but  to his disadvantage he  won't be able to
1. Reverse confirmed transactions
2.creat new coins
If someone has the majority control of hashing power then he  can decide which transactions to include in the next block.

Pages:
Jump to: