Financial economics — science or chance? Those of us who occasionally follow stock markets worldwide are usually well aware of the fact that ‘winners’ in these markets are largely the result of the harvest of chance. Occasionally, however, one hears so-called day traders express the view that it surely cannot be a question of pure luck that some stock traders consistently make winning transactions in the market. To test the sustainability of these opinions, one can amuse oneself by using a little Python script yours truly has made to simulate a chance scenario throwing a die and calculating the probability that at least one person out of 100 gets heads at least 9 times when each person flips a coin 10 times: import mathdef binomial_coefficient(n,
Topics:
Lars Pålsson Syll considers the following as important: Economics
This could be interesting, too:
Lars Pålsson Syll writes Crippling fiscal rules
Lars Pålsson Syll writes Anything we can actually do, we can afford
Lars Pålsson Syll writes The methods economists bring to their research
Lars Pålsson Syll writes Wie weiter mit der Schuldenbremse?
Financial economics — science or chance?
Those of us who occasionally follow stock markets worldwide are usually well aware of the fact that ‘winners’ in these markets are largely the result of the harvest of chance. Occasionally, however, one hears so-called day traders express the view that it surely cannot be a question of pure luck that some stock traders consistently make winning transactions in the market.
To test the sustainability of these opinions, one can amuse oneself by using a little Python script yours truly has made to simulate a chance scenario throwing a die and calculating the probability that at least one person out of 100 gets heads at least 9 times when each person flips a coin 10 times:
import math
def binomial_coefficient(n, k):
return math.factorial(n) // (math.factorial(k) * math.factorial(n – k))
def probability_single_person(n, k):
p = 0.5 # probability of heads for a fair coin
probability = 0
for i in range(k, n + 1):
probability += binomial_coefficient(n, i) *
(p ** i) * ((1 – p) ** (n – i))
return probability
def probability_at_least_one_person(num_people,
flips_per_person, min_heads):
single_prob = probability_single_person(flips_per_person,
min_heads)
return 1 – (1 – single_prob) ** num_people
# Parameters
num_people = 100 # number of people
flips_per_person = 10 # number of coin flips per person
min_heads = 9 # minimum number of heads for success
# Calculate the probability
probability = probability_at_least_one_person(num_people,
flips_per_person, min_heads)
print(f”The probability that at least one person out of
{num_people} gets heads at least {min_heads} times is approximately {probability:.4f} or {probability * 100:.2f}%”)