Links
Home Page
Picasa - Lide.cz - Google - Facebook - LinkedIn - Orkut - Twitter - IMDB Movies - FriendFeed - WikiLoc - EveryTrail - GPSies - ArtGallery
Picasa - Lide.cz - Google - Facebook - LinkedIn - Orkut - Twitter - IMDB Movies - FriendFeed - WikiLoc - EveryTrail - GPSies - ArtGallery
Thursday, May 28, 2020
Friday, May 15, 2020
Tuesday, May 5, 2020
Zbabělci
„Los! Die Fahne weg!“ křičel, když mu někde nestáhli vlajku dost rychle. Ulice před autem se taky vyprazdňovala. Kaldounovic vlajku někdo zatahoval do vikýře, jak nejrychleji mohl. Vypadalo to, jako kdyby vikýř polykal červeno‑bílý makarón. Tak. Honem to schovat. Přišli s tím trochu moc brzo. Honem, pryč s tím. Jen nepobouřit Němce. Aby revoluce byla v bezpečí. A byla v bezpečí. Tahle revoluce byla určitě v bezpečí. Docela určitě. Oficír s pistolí v ruce pozoroval se zájmem Kaldounovic vlajku. Auto skoro zastavilo. Díval se, jak vlajka mizí ve vikýři, a mlčel. Vtom se ale někde na fasádě zachytila. Ten, co ji vytahoval, počal s ní prudce škubat, ale držela pevně.
...
Vstal jsem, pozdvihl jsem slavnostně saxofon a rozvzlykal jsem se na počest vítězství a konce války, na počest tohohle města a všech jeho krásných dívek a na počest veliké, bezedné, věčné, pitomé, krásné lásky. A vzlykal jsem nad tím vším, nad svým životem, nad esesáky, které popravili, a nad chudákem Hrobem, který pad, nad Irenou, která nechápala a blížila se pomalu svojí zkáze v nějakém manželství, nad tím časem mládí, který skončil, a nad rozchodem, který začínal, nad orchestrem, který se už nikdy takhle nesejde, nad večery, kdy jsme hráli pod petrolejkama a mysleli na svět, který přijde, nad všemi těmi krásnými dívkami, které jsem miloval, a miloval jsem jich mnoho, snad všechny, a nad sluncem, a z oranžových a šafránových červánků na západě se ke mně skláněl nějaký nový a nově marný život, ale byl hezký a já jsem pozvedl třpytící se saxofon k němu a zpíval jsem a mluvil jsem z jeho pozlaceného korpusu, že ho přijímám, a že přijímám všechno, cokoliv přijde, protože nemohu nic dělat, a odněkud z té záplavy zlata a slunce se ke mně zase naklonila ta holka, co ji teprve potkám, a pohladila mě po tváři. Dole tancovali pásci, které jsem měl rád a které jsem měl za pár dní opustit, a měl jsem jít jinam, zase někam, a já jim hrál a myslel jsem na všechny ty obvyklé věci, na které jsem vždycky myslel, na holky a na jazz a na tu neznámou holku, kterou potkám v Praze.Sunday, May 3, 2020
Playing with Virus data
Thanksto the Sage for the mathematical framework,
to the ECDC for the worldwide pandemic data,
to the China for the virus,
we can now play with the statistics and create some interesting graphs,
- like the current number of days to double number of victims [should be high]
- or the exponent of the current cases grows (if considered exponential) [should be low].
import csv
from datetime import date
# ------------------------------------------------------------------------------
date0 = date(2019, 12, 31)
# ------------------------------------------------------------------------------
# Functions defining graphs
# Cases / Deaths
def cases(v):
return anything(v, 'cases')
def deaths(v):
return anything(v, 'deaths')
def anything(v, c):
v1 = {}
#for x in v:
# v1[x] = v[x][c]
for k in sorted(v.keys()):
v1[k] = v[k][c]
return v1
# Daily increase [%]
def delta_cases(v):
return delta_any(v, 'cases')
def delta_deaths(v):
return delta_any(v, 'deaths')
def delta_any(v, c):
v1 = {}
sum = 0
for k in sorted(v.keys()):
sum += v[k][c]
if sum != 0:
v1[k] = 100 * v[k][c] / sum
return v1
# Number of days to double numbers
def double_cases(v):
return double_any(v, 'cases')
def double_deaths(v):
return double_any(v, 'deaths')
def double_any(v, c):
v1 = {}
sum = 0
for k in sorted(v.keys()):
sum += v[k][c]
if v[k][c] != 0:
v1[k] = sum / v[k][c]
return v1
# Exponet for exponential fit of latest days
def exp_cases(v):
return exp_any(v, 'cases')
def exp_deaths(v):
return exp_any(v, 'deaths')
def exp_any(v, c):
v1 = {}
y0 = -1
for k in sorted(v.keys()):
if y0 > 0 and v[k][c] > 0:
v1[k] = log(float(v[k][c])) - y0
y0 = log(float(v[k][c]))
return v1
# Mortality
def mortality(v):
v1 = {}
sum = 0
for k in sorted(v.keys()):
sum += v[k]['deaths']
if v[k]['cases'] != 0:
v1[k] = 100 * v[k]['deaths'] / v[k]['cases']
return v1
# Sigmoid fit
def sigmoidFit(name, values):
data = []
sum = 0
for v in values:
sum += v[1]
data += [(v[0], sum)]
var('L, k, x0, x')
model(x) = L / (1 + exp(- k * (x - x0)))
sol = find_fit(data, model)
print(sol)
f(x) = model(L = sol[0].rhs(), k = sol[1].rhs(), x0 = sol[2].rhs())
h = plot([])
h += text(name, ( 30, sol[0].rhs() / 2 ), fontsize = 10, color = 'black')
h += text('today is ' + str(len(data) - round(sol[2].rhs())) + ' days after peak', (130, sol[0].rhs() / 2 * 0.9), fontsize = 10, color = 'black')
h += plot(f(x), x, [0, len(data) * 2])
h += list_plot(data, color = 'red')
show(h)
# Reading and interpreting country data
def readCountry(country, f, normalised, integrated, offset, smear):
val = {}
with open('virus.csv', newline='') as csvfile:
reader = csv.DictReader(csvfile)
for row in reader:
date1 = date(int(row['year']), int(row['month']), int(row['day']))
days = (date1 - date0).days
if row['countriesAndTerritories'] == country:
v = {}
if normalised:
v['cases'] = float(row['cases']) / float(row['popData2018'])
v['deaths'] = float(row['deaths']) / float(row['popData2018'])
else:
v['cases'] = int(row['cases'])
v['deaths'] = int(row['deaths'])
val[int(days)] = v
if integrated:
valI = {}
sumC = 0
sumD = 0
for k in sorted(val.keys()):
sumC += val[k]['cases']
sumD += val[k]['deaths']
valI[k] = {'cases':sumC, 'deaths':sumD}
val = valI
if smear > 0:
valS = {}
for k in sorted(val.keys()):
sumC = 0
sumD = 0
n = 0
for i in [0..smear]:
if k + i in val.keys():
n += 1
sumC += val[k + i]['cases']
sumD += val[k + i]['deaths']
valS[k] = {'cases':(sumC / n), 'deaths':(sumD / n)}
val = valS
if offset > 0:
valO = {}
d = 0
for k in sorted(val.keys()):
d += 1
if d > offset:
valO[k] = val[k]
val = valO
return f(val)
# Creating histogram
def plotHisto(values, logarithmic, col, country, doSpline):
data = []
maxx = 0
for val in values:
data += [(val, values[val])]
if val > maxx:
maxx = val
sc = 'linear'
if logarithmic:
sc = 'semilogy'
p = list_plot(data, scale = sc, color = col)
if (doSpline):
s = spline(data)
p += plot(s, 0, maxx, scale = sc, color = col, legend_label = country)
return p
# ------------------------------------------------------------------------------
# Define group of countries to analyse
countries = [
('France', 'red'),
('Italy', 'green'),
('Germany', 'grey'),
('Belgium', 'pink'),
('Russia', 'purple'),
('Spain', 'orange'),
('Czechia', 'blue'),
('Sweden', 'brown'),
('Japan', 'yellow'),
('United_Kingdom', 'violet'),
('United_States_of_America', 'black')
]
countries0 = [
('France', 'red'),
('Italy', 'green'),
('Czechia', 'blue')
]
countriesF = [
('France', 'red'),
]
# Set graphs to create
# - for analytical graphs
optionsList = [
{'normalised':true, 'integrated':false, 'logarithmic':false, 'smear':5, 'offset':60, 'doSpline':true, 'countries':countries, 'f':[cases, deaths]},
{'normalised':true, 'integrated':false, 'logarithmic':false, 'smear':0, 'offset':60, 'doSpline':true, 'countries':countries, 'f':[cases, deaths]},
{'normalised':true, 'integrated':true, 'logarithmic':false, 'smear':0, 'offset':60, 'doSpline':true, 'countries':countries, 'f':[cases, deaths]},
{'normalised':false, 'integrated':false, 'logarithmic':false, 'smear':0, 'offset':60, 'doSpline':true, 'countries':countries0, 'f':[cases, deaths]},
{'normalised':false, 'integrated':true, 'logarithmic':false, 'smear':0, 'offset':60, 'doSpline':true, 'countries':countries0, 'f':[cases, deaths]},
{'normalised':true, 'integrated':true, 'logarithmic':true, 'smear':5, 'offset':60, 'doSpline':true, 'countries':countries, 'f':[cases, deaths]},
{'normalised':false, 'integrated':false, 'logarithmic':false, 'smear':5, 'offset':60, 'doSpline':true, 'countries':countries, 'f':[delta_cases, delta_deaths]},
{'normalised':false, 'integrated':false, 'logarithmic':false, 'smear':5, 'offset':60, 'doSpline':true, 'countries':countries, 'f':[double_cases, double_deaths]},
{'normalised':false, 'integrated':false, 'logarithmic':false, 'smear':5, 'offset':60, 'doSpline':true, 'countries':countries, 'f':[exp_cases, exp_deaths]},
{'normalised':false, 'integrated':false, 'logarithmic':false, 'smear':10, 'offset':60, 'doSpline':true, 'countries':countries, 'f':[mortality]},
]
# - for sigmoid fit
countries4fit = countriesF
# ------------------------------------------------------------------------------
# Main loop for analytical graphs
for options in optionsList:
normalised = options['normalised']
integrated = options['integrated']
logarithmic = options['logarithmic']
smear = options['smear']
offset = options['offset']
doSpline = options['doSpline']
countries = options['countries']
for f in options['f']:
if f == delta_cases or f == delta_deaths or f == double_cases or f == double_deaths:
integrated = false
if f == exp_cases or f == exp_deaths:
integrated = true
normalised = false
#if integrated:
# offset = 0
h = plot([])
for (country, color) in countries:
h += plotHisto(readCountry(country, f, normalised, integrated, offset, smear), logarithmic, color, country, doSpline)
x = (3 * h.get_minmax_data()['xmin'] + h.get_minmax_data()['xmax']) / 4
y = (3 * h.get_minmax_data()['ymin'] + h.get_minmax_data()['ymax']) / 4
t = f.__name__
if normalised:
t += ",\nnormalised"
if integrated:
t += ",\nintegrated"
if logarithmic:
t += ",\nlogarithmic"
if smear > 0:
t += ",\nsmear = " + str(smear)
h += text(t, (x, y), fontsize = 10, color = 'black')
show(h)
# Main loop for sigmoid fit
for country in countries4fit:
for h in [cases, deaths]:
values = readCountry(country[0], h, false, false, 0, 0)
a = []
for v in values:
a += [(v, values[v])]
sigmoidFit(country[0] + "\n" + h.__name__, a)
# ------------------------------------------------------------------------------
Thursday, April 23, 2020
SIR with Sage
Very simple implementation of the SIR epidemic model using Sage mathematical framework.
# Infected
IInit = 1
# Susceptible
SInit = N - IInit
# Resistant
RInit = 0
# Transmission rate
betaInit = 0.5
# Transmission rate attenuation
delta = 0.01
# Recovery rate
gamma = 0.1
# Population size
N = 10000
# End time
tMax = 100
# Number of points
points = 1000
# Standard SIR model
def ODE_RHS(t, Y):
(S, I, R, beta) = Y
dS = - beta * S * I / N
dI = beta * S * I / N - gamma * I
dR = gamma * I
dbeta = - beta * delta
return (dS, dI, dR, dbeta)
# Set up numerical solution of ODE
solver = ode_solver(function = ODE_RHS,
y_0 = (SInit, IInit, RInit, betaInit),
t_span = (0, tMax),
algorithm = 'rk8pd')
# Numerically solve
solver.ode_solve(num_points = points)
# Plot solution
show(plot(solver.interpolate_solution(i = 0), 0, tMax, legend_label = 'S(t)', color = 'green')
+ plot(solver.interpolate_solution(i = 1), 0, tMax, legend_label = 'I(t)', color = 'red')
+ plot(solver.interpolate_solution(i = 2), 0, tMax, legend_label = 'R(t)', color = 'blue'))
|
Result:
Wednesday, April 22, 2020
Sigmoidal Fit
Thursday, April 9, 2020
We Will Win
We will win. When we concentrate, we can do almost anything - land on the Moon, control nuclear power, destroy the virus. And we will do it much faster than ever in history - thanks to the globalization.
The economy will reboot faster than most expect. This is not an economical crisis. Once all is over, we will travel more than ever, we will produce more then ever. We will create a big debt - and we will pay it by the inflation. Which is not a bad thing, inflation means that the rich pay more then others.
The only real danger are those people, lobbies and activists, who want to use the problems to pass their demagogic agenda, which they have failed to pass by the democratic means. We should not let them to profit from the crises.
The economy will reboot faster than most expect. This is not an economical crisis. Once all is over, we will travel more than ever, we will produce more then ever. We will create a big debt - and we will pay it by the inflation. Which is not a bad thing, inflation means that the rich pay more then others.
The only real danger are those people, lobbies and activists, who want to use the problems to pass their demagogic agenda, which they have failed to pass by the democratic means. We should not let them to profit from the crises.
Monday, April 6, 2020
Not the end
Now this is not the end.
It is not even the beginning of the end.
But it is, perhaps, the end of the beginning.
#WeWillMeetAgain
It is not even the beginning of the end.
But it is, perhaps, the end of the beginning.
#WeWillMeetAgain
Thursday, March 26, 2020
To Ticho
U nás na vesnici normálně člověk pořád slyší jezdit auta a motorky. Nad hlavou nám létávají letadla z letiště v Orly. A i když to vše utichne, v dálce je slyšet hukot dálnice A10.
Ale teď není slyšet nic. Skoro nikdo nejezdí, i dálnice je většinou prázdná. A policie to kontroluje. Letiště Orly zavírá. A když odpoledne nezpívají ptáci, a nefouká vítr, je úplně ticho. Občas je slyšet, jak přeletí včela nebo moucha. Jinak většinou nic.
Ve městech byl rámus vždy, ale na venkově asi bývalí lidé na takové ticho zvyklí. My jsme odvykli, a působí to opravdu děsivě. Jako z nějakého postapokaliptickeho fantastického filmu.
Ale teď není slyšet nic. Skoro nikdo nejezdí, i dálnice je většinou prázdná. A policie to kontroluje. Letiště Orly zavírá. A když odpoledne nezpívají ptáci, a nefouká vítr, je úplně ticho. Občas je slyšet, jak přeletí včela nebo moucha. Jinak většinou nic.
Ve městech byl rámus vždy, ale na venkově asi bývalí lidé na takové ticho zvyklí. My jsme odvykli, a působí to opravdu děsivě. Jako z nějakého postapokaliptickeho fantastického filmu.
Monday, March 9, 2020
Subscribe to:
Posts (Atom)



