Author

Topic: solomining probability calculator (Read 380 times)

hero member
Activity: 630
Merit: 731
Bitcoin g33k
April 09, 2023, 08:45:29 AM
#24
don't get your question? What exactly you're asking for ?
hero member
Activity: 595
Merit: 506
April 09, 2023, 08:42:03 AM
#23
Only skimmed the thread. Was there anything wrong with solochance in the end?
hero member
Activity: 504
Merit: 1065
Crypto Swap Exchange
February 15, 2023, 03:52:19 PM
#22
Hey OP !

Here is the French translation :

Code:
#!/usr/bin/env python3
##########################################
#         2023/Jan/28 by citb0in         #
#       https://github.com/citb0in       #
#                                        #
#   This project is licensed under the   #
#       terms of the GPLv3 license.      #
##########################################
import requests
import re

####################
# Some global vars #
####################

# Uncomment following line(s) for manually seting the difficulty/netrate to a value of your choice
#diff = 210453655497.094
#netrate = 1510000000000000000

# Number of chars to print as horizontal line separator, on a widescreen you could try 200
sep = 150

###########################
# Definitions (functions) #
###########################

def get_diff_and_netrate(diff_from_api=False,netrate_from_api=False):
    """Function for getting the current Bitcoin difficulty and network hashrate from API"""
    global diff
    global netrate
    if 'diff' not in globals() or 'netrate' not in globals():
        response = requests.get("https://mempool.space/api/v1/mining/hashrate/3d")
        print("Execution de la requête API pour recevoir les informations du réseau Bitcoin...\n")
        if response.status_code != 200:
            raise Exception("Èchec, impossible de recevoir les données depuis API")
        if 'diff' not in globals():
            diff = response.json()["currentDifficulty"]
            diff_from_api = True
        if 'netrate' not in globals():
            netrate = response.json()["currentHashrate"]
            netrate_from_api = True
    return diff, netrate, diff_from_api, netrate_from_api

def get_probability_single_hash():
    """Function to calculate the probability of a single hash solving a block"""
    # the target represents the number of valid hashes
    # ratio of all hashes over valid hashes => 2**256 / (0xffff*2**208 / D)
    ratio = diff * 2**48 / 0xffff
    prob = 1/ratio
    return ratio, prob

def get_proportion_of_netrate(hashrate):
    """Function to set the hashrate of the solominer in relation to the total network rate"""
    proportion = hashrate_raw / netrate * 100
    if "e-" in str(proportion):
        precision = 1
        netrate_prec = int(str(proportion).split("e-")[1]) + precision
    else:
        netrate_prec = re.search(r"[1-9]", str(proportion)).start()
    return proportion, netrate_prec

def format_input(hashrate_raw):
    """Function for formatting the input hashrate"""
    hashrate_match = re.match(r'^\s*([0-9]+(?:\.[0-9]+)?)\s*([KMGTPEZY]?)\s*(H)?\s*(\/)?\s*(s|sec)?\s*$', hashrate_raw, flags=re.IGNORECASE)
    if hashrate_match:
        hashrate_nounit = float(hashrate_match.group(1))
        hashrate_unit = hashrate_match.group(2).upper()
        conversions = {'K': 1e3, 'M': 1e6, 'G': 1e9, 'T': 1e12, 'P': 1e15, 'E': 1e18, 'Z': 1e21, 'Y': 1e24}
        if hashrate_unit in conversions:
            hashrate_raw = hashrate_nounit*conversions[hashrate_unit]
        else:
            hashrate_raw = hashrate_nounit
    else:
        return None
    return hashrate_nounit, hashrate_unit, hashrate_raw

def scale_unit(value):
    """Function for scaling to highest possible unit"""
    units = ['', 'K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y']
    value = str(value)
    prefix = ''
    if ' ' in value:
        value, prefix = value.split()
    exponent = 0
    while float(value) >= 1000:
        value = str(float(value) / 1000)
        exponent += 1
    return f"{float(value):.2f} {units[exponent]}{prefix}"

def calculate_probability(hashrate):
    """Function for calculating the probability per block avg. time of 10min for use as a base"""
    expected_blockhit_time = diff * 2**48 / 0xffff / hashrate_raw / 3600
    expected_blockhit_rel_net = netrate / hashrate_raw * 600
    prob_per_10min = hashrate_raw / (diff * 2**48 / 0xffff) * 600
    prob_per_block = prob_per_10min
    if "e-" in str(prob_per_10min):
        # Number of desired additional decimal places
        # beginning from first occurring decimal place not equal to zero
        precision = 2
        prob_prec = int(str(prob_per_10min).split("e-")[1]) + precision
    else:
        prob_prec = 3
    # Define some additional time units
    prob_per_hour = prob_per_block * 6
    prob_per_day = prob_per_hour * 24
    prob_per_week = prob_per_day * 7
    prob_per_month = prob_per_day * 30
    prob_per_halfyear = prob_per_day * 182.5
    prob_per_year = prob_per_day * 365
    return expected_blockhit_time, expected_blockhit_rel_net, prob_per_block, prob_per_hour, prob_per_day, prob_per_week, prob_per_month, prob_per_halfyear, prob_per_year, prob_prec, netrate_prec

def probability_phrase(probability):
    if probability <= 0.00001:
        return "plus de chances d'être frappé par un éclair"
    elif probability <= 0.0001:
        return "plus de chances de gagner au Lotto"
    elif probability <= 0.45:
        return "les chances sont contre vous en théorie"
    elif probability <= 0.55:
        return "aussi probable que de tirer à pile ou face et d'obtenir face."
    elif probability <= 0.00001:
        return "plus probable que de trouver une aiguille dans une botte de foin."
    elif probability <= 0.001:
        return "aussi probable que de faire un trou en un au golf."
    elif probability <= 0.000001:
        return "probabilité similaire à celle de trouver un grain de sable spécifique sur une plage"
    elif probability <= 0.001:
        return "aussi probable que d'obtenir un score parfait à un jeu de fléchettes."
    elif probability <= 0.5:
        return "improbable"
    else:
        return "plus probable que non"

def describe_probability(prob):
    if prob >1:
        return "une garantie, une chose sûre à 100% - vous pouvez parier votre dernier dollar là-dessus. Ça va arriver bientôt ! YEAH ! !!"
    if prob >= 0.99 and prob <= 1:
        return "pratiquement certain, presque une garantie - c'est similaire à la probabilité que le soleil se lève demain."
    elif prob >= 0.98 and prob < 0.99:
        return "extrêmement probable, presque une certitude - c'est similaire à la probabilité qu'une équipe de football gagne un match lorsqu'elle mène de 14 points à 2 minutes de la fin."
    elif prob >= 0.95 and prob < 0.98:
        return "très probable, hautement probable - c'est similaire à la probabilité qu'un lanceur de baseball lance un strike avec un compte de 3-2."
    elif prob >= 0.9 and prob < 0.95:
        return "C'est un peu comme la probabilité qu'un golfeur fasse un putt d'un mètre cinquante."
    elif prob >= 0.8 and prob < 0.9:
        return "plus probable que non - c'est similaire à la probabilité qu'une équipe de basket-ball réussisse un lancer franc."
    elif prob >= 0.7 and prob < 0.8:
        return "C'est un peu comme la probabilité qu'une équipe de football marque un touchdown dans une zone rouge."
    elif prob >= 0.6 and prob < 0.7:
        return "C'est un peu comme la probabilité qu'une prévision météorologique annonce de la pluie et qu'il pleuve réellement."
    elif prob >= 0.5 and prob < 0.6:
        return "C'est un peu comme la probabilité de tirer à pile ou face et d'obtenir pile du premier coup."
    elif prob >= 0.4 and prob < 0.5:
        return "assez probable - elle est similaire à la probabilité de tirer une carte rouge d'un jeu de cartes à jouer standard"
    elif prob >= 0.3 and prob < 0.4:
        return "moins probable que non - c'est similaire à la probabilité qu'une équipe de baseball remporte un match alors qu'elle est menée par quatre points dans le bas de la neuvième manche."
    elif prob >= 0.2 and prob < 0.3:
        return "improbable, tout à fait improbable - c'est un peu comme la probabilité de deviner la bonne combinaison d'une serrure à trois chiffres du premier coup."
    elif prob >= 0.1 and prob < 0.2:
        return "très improbable, hautement improbable - c'est comme la probabilité d'obtenir un nombre spécifique en lançant un dé juste."
    elif prob >= 0.01 and prob < 0.1:
        return "Extrêmement improbable - c'est comme tirer à pile ou face et obtenir pile 10 fois de suite."
    elif prob >= 0.001 and prob < 0.01:
        return "pratiquement impossible - c'est comme lancer une pièce de monnaie et obtenir pile 100 fois de suite."
    elif prob >= 0.0001 and prob < 0.001:
        return "pratiquement impossible - il est plus probable d'être frappé par la foudre deux fois au même endroit ou de recevoir une quinte royale au poker dès la première main."
    elif prob >= 0.00005 and prob < 0.0001:
        return "pratiquement impossible - il est plus probable d'être frappé par la foudre dans une vie."
    elif prob >= 0.00001 and prob < 0.00005:
        return "pratiquement impossible - c'est comme si un individu donné était frappé par la foudre plusieurs fois dans sa vie."
    elif prob >= 0.000001 and prob < 0.00001:
        return "pratiquement impossible - c'est comme la probabilité de gagner un prix dans une loterie avec 1 chance sur 10 millions."
    elif prob >= 0.0000005 and prob < 0.000001:
        return "pratiquement impossible - c'est comme la probabilité d'obtenir une combinaison spécifique de cinq numéros sur une machine à sous."
    elif prob >= 0.00000005 and prob < 0.0000005:
        return "pratiquement impossible - il est plus probable de gagner le jackpot de la loterie Powerball ou Mega Millions."
    elif prob < 0.00000005:
        return "infiniment petit - c'est similaire à la probabilité de trouver un atome spécifique parmi tous les atomes de l'univers."
    else:
        return "discutable ? !"

#######################################
# Program flow / variable assignments #
#######################################

# User input hash rate
hashrate_input = input("Entrer le hashrate/sec de votre équipement solo : ")

# Call the functions and fill the variables
diff, netrate, diff_from_api, netrate_from_api = get_diff_and_netrate()
diff_formatted, netrate_formatted = scale_unit(diff), scale_unit(netrate)+"H/s"
hashrate_nounit, hashrate_unit, hashrate_raw = format_input(hashrate_input)
proportion, netrate_prec = get_proportion_of_netrate(hashrate_raw)
expected_blockhit_time, expected_blockhit_rel_net, prob_per_block, prob_per_hour, prob_per_day, prob_per_week, prob_per_month, prob_per_halfyear, prob_per_year, prob_prec, netrate_prec = calculate_probability(hashrate_raw)
single_ratio, single_prob = get_probability_single_hash()

##########
# Output #
##########

print(f"{'Choisir la difficulté manuellement:' if not diff_from_api else 'La difficulté actuelle de Bitcoin est :'} {diff:,.3f} ({diff_formatted})\n{'Hashrate total du réseau Bitcoin:' if not netrate_from_api else 'Le hashrate total de tout le réseau Bitcoin:'} {netrate:,.2f} ({netrate_formatted})\n")
print('\nLe ratio de tous les hash par rapport aux shares valides est de:\n1 hash sur {:,.0f}'.format(single_ratio),'donnera un block potentiellement valide.\nOu chaque hash a une chance de miner un block de {:,.30f} %'.format(single_prob))
print('=' * sep)
print(f'\nLe hashrate entré de {hashrate_nounit} {hashrate_unit}H/sec équivaut à: {hashrate_raw:,.2f} hash/sec\n Le ratio de votre hashrate par rapport au réseau BTC est de: {proportion:,.{netrate_prec}f} %\n')
print('=' * sep)
# Display probability as decimal value, percentage, "1 in x" format and as description / analogy text
print(f'Chances par 10 min: {prob_per_block:,.{prob_prec}f} ({prob_per_block*100:,.{prob_prec}f} %) ou 1 sur {1/prob_per_block:,.0f}')
print(f'\nLa chance de miner un block avec le hashrate donné dans un délai de 1 an est similaire à la probabilité de choisir une boule rouge gagnante dans un bocal contenant {str(describe_probability(prob_per_block))}')
print('=' * sep)
print(f'Chances par heures: {prob_per_hour:,.{prob_prec}f} ({prob_per_hour*100:,.2f} %) ou 1 sur {1/prob_per_hour:,.0f}')
print(f'\nLa chance de miner un block avec le hashrate donné dans un délai de 1 an est similaire à la probabilité de choisir une boule rouge gagnante dans un bocal contenant {int(round(1/prob_per_hour,0)):,} boules blanches. Ou alors, la probabilité que cela se produise est de  {str(describe_probability(prob_per_hour))}')
print('=' * sep)
print(f'Chances par jours: {prob_per_day:,.{prob_prec}f} ({prob_per_day*100:,.2f} %) ou 1 sur {1/prob_per_day:,.0f}')
print(f'\nLa chance de miner un block avec le hashrate donné dans un délai de 1 an est similaire à la probabilité de choisir une boule rouge gagnante dans un bocal contenant  {int(round(1/prob_per_day,0)):,} boules blanches. Ou alors, la probabilité que cela se produise est de  {str(describe_probability(prob_per_day))}')
print('=' * sep)
print(f'Chances par semaines: {prob_per_week:,.{prob_prec}f} ({prob_per_week*100:,.2f} %) ou 1 sur {1/prob_per_week:,.0f}')
print(f'\nLa chance de miner un block avec le hashrate donné dans un délai de 1 an est similaire à la probabilité de choisir une boule rouge gagnante dans un bocal contenant  {int(round(1/prob_per_week,0)):,} boules blanches. Ou alors, la probabilité que cela se produise est de  {str(describe_probability(prob_per_week))}')
print('=' * sep)
print(f'Chances par mois: {prob_per_month:,.{prob_prec}f} ({prob_per_month*100:,.2f} %) ou 1 sur {1/prob_per_month:,.0f}')
print(f'\nLa chance de miner un block avec le hashrate donné dans un délai de 1 an est similaire à la probabilité de choisir une boule rouge gagnante dans un bocal contenant {int(round(1/prob_per_month,0)):,} boules blanches. Ou alors, la probabilité que cela se produise est de  {str(describe_probability(prob_per_month))}')
print('=' * sep)
print(f'Chances par demi-années: {prob_per_halfyear:,.{prob_prec}f} ({prob_per_halfyear*100:,.2f} %) ou 1 sur {1/prob_per_halfyear:,.0f}')
print(f'\nLa chance de miner un block avec le hashrate donné dans un délai de 1 an est similaire à la probabilité de choisir une boule rouge gagnante dans un bocal contenant  {int(round(1/prob_per_halfyear,0)):,} boules blanches. Ou alors, la probabilité que cela se produise est de  {str(describe_probability(prob_per_halfyear))}')
print('=' * sep)
print(f'Chances par années: {prob_per_year:,.{prob_prec}f} ({prob_per_year*100:,.2f} %) ou 1 sur {1/prob_per_year:,.0f}')
print(f'\nLa chance de miner un block avec le hashrate donné dans un délai de 1 an est similaire à la probabilité de choisir une boule rouge gagnante dans un bocal contenant {int(round(1/prob_per_year,0)):,} boules blanches. Ou alors, la probabilité que cela se produise est de {str(describe_probability(prob_per_year))}')
print('=' * sep)
print(f'Temps attendu moyen pour miner un block :\n{expected_blockhit_time*3600:,.1f} sec = {expected_blockhit_time*60:,.1f} min = {expected_blockhit_time:,.1f} h = {expected_blockhit_time/24:,.1f} jours = {expected_blockhit_time/24/7:,.1f} semaines = {expected_blockhit_time/24/7/4.34:,.1f} mois = {expected_blockhit_time/24/7/4.34/12:,.1f} années\n')
print(f'Temps attendu moyen (en fonction de tout le réseau):\n{expected_blockhit_rel_net:,.1f} sec = {expected_blockhit_rel_net/60:,.1f} min = {expected_blockhit_rel_net/60/60:,.1f} h = {expected_blockhit_rel_net/60/60/24:,.1f} jours = {expected_blockhit_rel_net/60/60/24/7:,.1f} semaines = {expected_blockhit_rel_net/60/60/24/7/4.34:,.1f} mois = {expected_blockhit_rel_net/60/60/24/7/4.34/12:,.1f} années')
print('=' * sep)
newbie
Activity: 23
Merit: 35
February 05, 2023, 05:43:56 AM
#21
the correct answer in my opinion is

1- [chance with 50 PH/s for 3h] = [chance with 25 PH/s for 6h] = [chance with 5 PH/s for 30h]

because it takes into account the shares submitted.

The problem can be generalized to :

is [chance with x bets in n attempts] = or > [chance with x/y bets in y*n attempts] ?

My answer is based on these extreme case examples :

1) Alice bets on the 6 numbers of the dice and rolls it 1 time  --> Alice is 100% sure of hitting a number

2) Bod bets on 1 number of the dice but rolls it 6 times          --> Bob may not hit a number (even if he bets on the same number). But he is "expected" to hit a number if he increases the number of his attempts.

For me this is why strictly speaking [chance with x bets in n attempts] > [chance with x/y bets in y*n attempts] .

3) Let's assume that Bob bets always on the same number    --> The probability of hitting this number at least one = 66.5% in 6 rolls or = 98.7% in 24 rolls (1-(5/6)^n for the formula).

In the case of bitcoin mining, the winning number is new every 10 min. Then what matters is the available hash rate during these 10 min.

The discussion is interesting, I'll be glad of hearing clarifications from experts.
hero member
Activity: 630
Merit: 731
Bitcoin g33k
January 31, 2023, 08:44:46 AM
#20
@NotATether:
You seem to have something mixed up. I intensionally created the quoted error message to show that in case of unreachability Python would produce an error like the one shown. I did this by just blocking my computer from being able to access the mempool.space domain. Since this is apparently not the case with iwantmyhomepaidwithbtc2, the problem is buried somewhere else. The Python tool has already been constructed with error checking in mind, so it would generate an error. Also, maxretries refers to Pythons' functionality of requesting a URL on invocation. This is not an error message or restriction on mempool.space's part because my computer wasn't able to connect to the domain mempool.space at all during this intentional test.

However, I have updated the error handler so you will receive an error when something's going wrong.

legendary
Activity: 1568
Merit: 6660
bitcoincleanup.com / bitmixlist.org
January 31, 2023, 08:22:53 AM
#19
weird but understood. When the python tool is not able to connect to the mempool.space URL it would throw an error like:
Quote
ConnectionRefusedError: [Errno 111] Connection refused
urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='mempool.space', port=443): Max retries exceeded with url: /api/v1/mining/hashrate/3d (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused'))
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='mempool.space', port=443): Max retries exceeded with url: /api/v1/mining/hashrate/3d (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused'))

in your case it seems to have another root causing that but without any debug message or helpful information I'm not able to provide further assistance, I'm sorried. I only can suggest to wipe your current working directory of the solomining probability calculator and redownload and begin from scratch just to ensure the download/gitclone went ok.

It's a rate limiting error, as you can see with "Max retries exceeded with url". It means that your programming loop is calling the API too many times and you should probably introduce a sleep timer if you haven't already, or make it longer.

Or you could use another proxy/VPN to bypass the IP ban, but I do not recommend it because calls that are being made too frequently will get the IP address banned again.
legendary
Activity: 2618
Merit: 1504
January 31, 2023, 07:50:46 AM
#18
The mention of the difficulty of the network is confusing because in the final case, the probability of finding a block in solo is calculated based on the speed of the miner and the total hashrate of the bitcoin network or is the difficulty of the network still used in the calculation?
For example NiceHash does not take into account the current difficulty of the bitcoin network https://www.nicehash.com/blog/post/how-is-solo-mining-probability-calculated?lang=en

this is something you need to distinguish between.

If you take the overall network hash power and divide by solo miners hashrate you get a ratio which represents your contribution proportion to the network. This ratio (= you have n-th xH/s of the overall network rate) gives you on average how many blocks will occur before you hit one. Your hash rate is put in relation to the total network. I know many sites out there use this way but it's not the key one. I added this information additionally to my tool to simply have a comparison to ...

The most important calculation though is based solely on the difficulty of the Bitcoin network to calulcate the probability of finding the right hash solving a block. What does that mean? There is a certain amount of valid hashes and the target. To win / solving a block you need to find a hash that is below or equal to the current network target. As we know both values we can calculate the ratio. For this calculation you only need the difficulty and solominers hash rate and it represents the probabaility of finding the winning hash which will solve the block. There is no relation to the total network, you do not compete against other miners because each single hash attempt has a winning chance.

Thanks for the explanation, but the main thing here is still the ratio of your miner's speeds to the total hashrate of the network, and the difficulty of the network has about the same value in finding a block in solo mining as luck.
hero member
Activity: 630
Merit: 731
Bitcoin g33k
January 30, 2023, 04:39:09 AM
#17
The mention of the difficulty of the network is confusing because in the final case, the probability of finding a block in solo is calculated based on the speed of the miner and the total hashrate of the bitcoin network or is the difficulty of the network still used in the calculation?
For example NiceHash does not take into account the current difficulty of the bitcoin network https://www.nicehash.com/blog/post/how-is-solo-mining-probability-calculated?lang=en

this is something you need to distinguish between.

If you take the overall network hash power and divide by solo miners hashrate you get a ratio which represents your contribution proportion to the network. This ratio (= you have n-th xH/s of the overall network rate) gives you on average how many blocks will occur before you hit one. Your hash rate is put in relation to the total network. I know many sites out there use this way but it's not the key one. I added this information additionally to my tool to simply have a comparison to ...

The most important calculation though is based solely on the difficulty of the Bitcoin network to calulcate the probability of finding the right hash solving a block. What does that mean? There is a certain amount of valid hashes and the target. To win / solving a block you need to find a hash that is below or equal to the current network target. As we know both values we can calculate the ratio. For this calculation you only need the difficulty and solominers hash rate and it represents the probabaility of finding the winning hash which will solve the block. There is no relation to the total network, you do not compete against other miners because each single hash attempt has a winning chance.
legendary
Activity: 2618
Merit: 1504
January 30, 2023, 03:07:46 AM
#16
The mention of the difficulty of the network is confusing because in the final case, the probability of finding a block in solo is calculated based on the speed of the miner and the total hashrate of the bitcoin network or is the difficulty of the network still used in the calculation?
For example NiceHash does not take into account the current difficulty of the bitcoin network https://www.nicehash.com/blog/post/how-is-solo-mining-probability-calculated?lang=en
hero member
Activity: 630
Merit: 731
Bitcoin g33k
January 29, 2023, 10:39:23 AM
#15
weird but understood. When the python tool is not able to connect to the mempool.space URL it would throw an error like:
Quote
ConnectionRefusedError: [Errno 111] Connection refused
urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='mempool.space', port=443): Max retries exceeded with url: /api/v1/mining/hashrate/3d (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused'))
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='mempool.space', port=443): Max retries exceeded with url: /api/v1/mining/hashrate/3d (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused'))

in your case it seems to have another root causing that but without any debug message or helpful information I'm not able to provide further assistance, I'm sorried. I only can suggest to wipe your current working directory of the solomining probability calculator and redownload and begin from scratch just to ensure the download/gitclone went ok.
hero member
Activity: 504
Merit: 1065
Crypto Swap Exchange
January 29, 2023, 10:29:56 AM
#14
Did you satisfy the requirements

Quote
Prerequisites

Note: Python2 is not supported.

    Python3 libs requests, re


you need python library "requests" to have this work. Just run
Code:
pip3 install requests

or

Code:
pip install requests


Yes I confirm that requirements are ok
I will continue to search for the reason of failure, but in waiting for that, the tool is working fine with manually settings
hero member
Activity: 630
Merit: 731
Bitcoin g33k
January 29, 2023, 10:14:50 AM
#13
Did you satisfy the requirements

Quote
Prerequisites

Note: Python2 is not supported.

    Python3 libs requests, re


you need python library "requests" to have this work. Just run
Code:
pip3 install requests

or

Code:
pip install requests
hero member
Activity: 504
Merit: 1065
Crypto Swap Exchange
January 29, 2023, 05:05:22 AM
#12
No more sign of life, when I do CTRL+C I have this : https://imgur.com/uonGnPh
Sorry, I am a total noob with python

Well, I am pretty sure I know the reason therefore. The tool by default tries to get the current difficulty and network hashrate by https://mempool.space site. In case you're computer is restricted (by firewall or similar) it cannot get the information. If it fails in accessing the URL it should return an error though so I'm puzzled you didn't get an error. However you can quickly find out if this is the reason. Just edit the code and uncomment the two lines:

from:
Quote
# Uncomment following line(s) for manually seting the difficulty/netrate to a value of your choice
#diff = 37590453655497.094
#netrate = 77889900112233.555


Thank you it works very nice with the manual diff and netrate.
Strange, because I go on mempool.space on a daily basis, and have all the necessary libs installed

Thank you for your help


hero member
Activity: 630
Merit: 731
Bitcoin g33k
January 29, 2023, 04:50:44 AM
#11
No more sign of life, when I do CTRL+C I have this : https://imgur.com/uonGnPh
Sorry, I am a total noob with python

Well, I am pretty sure I know the reason therefore. The tool by default tries to get the current difficulty and network hashrate by https://mempool.space site. In case you're computer is restricted (by firewall or similar) it cannot get the information. If it fails in accessing the URL it should return an error though so I'm puzzled you didn't get an error. However you can quickly find out if this is the reason. Just edit the code and uncomment the two lines:

from:
Indeed, it's irrelevant. Difficulty and your hash rate is what determines the odds to solve a block. I just saw the 600 seconds and misunderstood. So what does "3600" in expected_blockhit_time mean?

If you omit the 3600 you calculated the expected time related to one second because the hashrate is in "per second" unit. So you have to divide by 3600 to get to the 10min average.
legendary
Activity: 1512
Merit: 7340
Farewell, Leo
January 28, 2023, 06:29:58 PM
#10
However, I don't understand why and in what way a potential difference of 0.3 seconds affects you or makes you doubt the result? The 600 seconds are not fixed.
Indeed, it's irrelevant. Difficulty and your hash rate is what determines the odds to solve a block. I just saw the 600 seconds and misunderstood. So what does "3600" in expected_blockhit_time mean? Also, while practically zero, day doesn't have exactly 24 hours, so the time unit might be slightly inaccurate.
hero member
Activity: 504
Merit: 1065
Crypto Swap Exchange
January 28, 2023, 06:11:06 PM
#9
Code:
git clone https://github.com/citb0in/solomining_probability_calc.git
Code:
cd solomining_probability_calc
Code:
python3 solomining_probability_calc.py

Yeah I followed these steps

Quote
so you get the user input line where you have to enter your hash rate, right?

Yeap, I did a screenshot (cannot post here because of low rank) :https://imgur.com/z21uO7g

No more sign of life, when I do CTRL+C I have this : https://imgur.com/uonGnPh

Sorry, I am a total noob with python
hero member
Activity: 630
Merit: 731
Bitcoin g33k
January 28, 2023, 06:00:10 PM
#8
But I don't have any output
That's odd. What steps did you do? Basically it's as simple as
Code:
git clone https://github.com/citb0in/solomining_probability_calc.git
Code:
cd solomining_probability_calc
Code:
python3 solomining_probability_calc.py

I enter the hashrate (example "300t") and have 0 response in my terminal
so you get the user input line where you have to enter your hash rate, right?

Out of topic : I will do the translations to French in the following days, as I saw on your Github page that it is on your roadmap

Great! thank you in advance.
hero member
Activity: 504
Merit: 1065
Crypto Swap Exchange
January 28, 2023, 05:57:15 PM
#7
Thank you for this very useful tool !

The idea is top.

But I don't have any output
I enter the hashrate (example "300t") and have 0 response in my terminal

Even after 10 minutes - same issue.
I use python3

Out of topic : I will do the translations to French in the following days, as I saw on your Github page that it is on your roadmap
hero member
Activity: 630
Merit: 731
Bitcoin g33k
January 28, 2023, 05:11:01 PM
#6
Line #93 which you're referring to simply calculates the prob related to the overall network hash rate and was an additional metric that I added as a comparison out of curiosity. The key calculation and which is being used as a base is done Line #92 and this depends solely to the current target (which results in the human-readable difficulty value).

In the output you get both results so you can compare.

However, I don't understand why and in what way a potential difference of 0.3 seconds affects you or makes you doubt the result? The 600 seconds are not fixed. It also doesn't really matter if we refer to 600 seconds, 597, 612 seconds or whatever. Therefore also the different time relations, in order to show different examples to the reader. I see the 0.3 seconds therefore as irrelevant in this way of looking at it, but I like to be taught better.

Regarding the analogy phrases... I have taken the example with the atoms for all probabilities < 0.00000005. These are approx. 10^82 and the tiny number has accordingly many zeros. Surely other analogies would fit better in the category nearer to 0.00000005 like "It's more likely to flip a coin and getting heads 23 times in a row" or similar. The analogy phrases can certainly be reworked, that's why it's written as to-do in the roadmap of this project. If you have suggestions, I will gladly accept them and incorporate them.
legendary
Activity: 1512
Merit: 7340
Farewell, Leo
January 28, 2023, 04:53:32 PM
#5
For a software that has to accurately return the probability of hitting a block yourself, I have to be pedantic. In #L93, I see a netrate divided with hashrate times 600, which I believe is the expected time the network will hit a block. I presume that the 600 determines the seconds, hence the 10 minutes. The seconds aren't exactly 600 though, but 600.3 because of a long standing bug.

As for probabilities, are you sure that's true, because I doubt:
Code:
elif prob < 0.00000005:
        return "infinitesimally small - it's similar to the probability of finding a specific atom among all the atoms in the universe."

Seems more like practically not going to happen to me.
hero member
Activity: 630
Merit: 731
Bitcoin g33k
January 28, 2023, 03:43:15 PM
#4
the correct answer in my opinion is

1- [chance with 50 PH/s for 3h] = [chance with 25 PH/s for 6h] = [chance with 5 PH/s for 30h]

because it takes into account the shares submitted.
legendary
Activity: 2436
Merit: 6643
be constructive or S.T.F.U
January 28, 2023, 03:36:27 PM
#3
It's good that you started a new topic for what seemed to be a bit off-topic in the other thread,  I don't think it was important to quote everything from that thread, it will be difficult for other members to follow the logic of the discussion.

I think it's better to sum up the whole thing in a single question.

When mining bitcoin within the same difficulty epoch, which one of the following is correct and why?

Quote
1- [chance with 50 PH/s for 3h] = [chance with 25 PH/s for 6h] = [chance with 5 PH/s for 30h]


Quote
2- [chance with 50 PH/s for 3h] > [chance with 25 PH/s for 6h] > [chance with 5 PH/s for 30h]

hero member
Activity: 630
Merit: 731
Bitcoin g33k
January 27, 2023, 07:30:40 PM
#2
hero member
Activity: 630
Merit: 731
Bitcoin g33k
January 27, 2023, 07:24:23 PM
#1
Hello all,

The following post grew out of a discussion of another post. There the user akaki had criticized that in solomining one cannot simply multiply the calculated probability of a block hit per block average time of 10min with any desired time frame that would result in the probability e.g. for 1h, or a day, or a year. The user mikeywith has thankfully countered with very informative posts and explained the opposite. Since I wanted to dedicate myself to this topic intensively and learn more, I made a learning project out of it and wrote a Python program in parallel, which I constantly extended. This way I could try out different approaches and implement my learning into a working program right away.

At this point again a BIG THANKS to @mikeywith, who has really animated me to do this and has helped with his valuable explanations on.

I had already recommended the moderators to move the corresponding posts #46 - #56 to a new thread here in the technical forum, since this has become off-topic after all, but the mods probably haven't seen or wanted to implement that yet. I think it is appropriate to move the discussion here on technica part of the forum so that it is clear to everyone what it was actually about and on this way more information and a good discussion could follow.

All this resulted in the following python tool which I have uploaded to my repository [1] and would like to share with interested parties. I would like to add that I'm a complete Python beginner and still taking the first steps, so bear with me and correct me if you find any gross errors. I am also open to recommendations or constructive advice and will try to implement them in my free time. The goal is to learn and continue to have fun.

The "Solomining Probability Calculator" is a tool designed to assist solo miners in understanding their chances of successfully mining a block on the Bitcoin network. The program takes the user's hash rate as input, supporting various formats for ease of use. It also retrieves the current Bitcoin network difficulty which is then used to calculate a range of important mining metrics. These include the ratio of all hashes over the valid hashes, the probability of each single hash attempt, expected time to mine a block and the probability of successfully mining a block for various time frames. Additionally, the program offers helpful analogy and phrases to provide a better human-understanding of the probabilities, making it easier for users to interpret the results. With this tool, solo miners can gain valuable insights into their mining operations and make more informed decisions. Overall, the solomining probability calculator is a valuable tool for any solo miner looking to increase their chances of success in the competitive world of cryptocurrency mining.

If you like it and are interested, I could imagine to move the function to a website. This is because I have found that the solochance.com website that I am familiar with does not include current Difficulty values, and thus the calculations are not accurate when I compare them to others and my own calculations. I may be wrong, but I suspect that the relevant values like "difficulty" or "nbits" are not kept up to date there or may be manually entered by the operator from time to time. That would explain the deviation. For this reason, I was thinking about using my existing Python program as a basic framework to create a website with that functionality and output. I think I would have to rewrite that in JavaScript, which would be again (almost) new territory for me but if there is great interest then I would tackle that. Just let me know.

Have fun and a nice weekend.
citb0in

[1] https://github.com/citb0in/solomining_probability_calc
Jump to: