In the news, we are told that Covid-19 has killed 37,841 people as of 4/18/2020. While the rate has varied, it seems to be about 2100-2200 people per day. So let's get some context around that.
The population of the US is approximately 330 million people. The average life expectancy is 78.5 years. This means that each year, 4.2 million people die. That is 11,517 people per day. So what we are saying seems to be that an extra 20% of death is being handed out? Not necessarily. Later, government statistics will come out to determine whether Covid-19 was killing people in addition to normal causes of death, or rather instead of normal causes of death.
Repeating the calculation for Oregon, with the same life expectancy and a population of 4.2 million, normally 147 people die each day. Currently, the number of deaths from Covid-19 seems to be about 4 or 5 people per day. This is a much lower rate in comparison to the national picture. Here one might argue that it is much more likely that people are being killed by Covid-19 rather than some other causes such as traffic and gun accidents because of social distancing measures. In other words, probably Covid-19 is not adding to the death toll, people are dying at the same rate as before but for different reasons. Unfortunately, data compilation, validation and publishing take time, so resources such as CDC's Wonder are not going to answer just what kind of effect Covid-19 has had on the country until later.
Just also want to note that I have way simplified the subject. There are regional and seasonal variations. The short term effect of social distancing may be very hard to determine vs. the effect of the Covid-19 infection rate. Assumptions of paribus ceteris may be invalid for many reasons. Also, it is not clear that we have reached the peak of the mortality curve for the US or the deaths from Covid-19 could possibly remain level for some weeks. In the case of a doubling of the daily death rate or a sustained high level, then clearly the virus is adding marginally to the death rate and the life expectancy will go down when they calculate the statistics. For example, if we assume that 2200 daily deaths are indeed on top of the normal national death rate, then this would reduce the life expectancy to 65.9 years which is a pretty significant reduction.
Again, I want to stress that we won't be able to figure out the actual effects until all the data has been gathered and analyzed but it sure is fun to speculate about it.
Thoughts on politics and policy and whatever else strikes my fancy. Currently looking at Presidential documents issued by the current administration, previously a section by section review of the Oregon State Constitution.
Search This Blog
Saturday, April 18, 2020
Saturday, April 11, 2020
Random Alien Writing
I've been thinking about this for some time and finally found some time to write the program. The program is at the bottom of the post and written with Python 3.8. Basically, it creates a canvas filled with strange looking writing. I was inspired by some of the examples of "alien" writing used in various sci-fi movies and TV shows. I thought to myself, should be easy to create a program that can create examples of this kind of writing. I re-used the basic framework I had developed for the program to simulate cellular automata. (I have re-used the framework for some other bits I've made for myself, not (yet) posted here and it is becoming one of my favorites.) My first attempts, frankly, looked like white noise on a screen. Over a couple of days I refined the parameters to get it closer to what the brain will recognize as having some semantic content and organization and the current version is pretty good. I've used it to generate the background I've added to the blog. I hope you like it! I'm not going to go into a detailed explanation of the program elements, but if you have questions about it, post a comment.
from tkinter import *
from random import randint
class App:
"""This class is derived, I think, from a TK class and is designed to
work with the TK environment.
Requires imports from Tkinter, math, and random"""
def __init__(self, master):
"""This class is the whole of the application """
# Necessary Frames
frame = Frame(master)
control_frame = Frame(frame)
control_frame.grid(row = 0, column = 0, sticky = N)
canvas_frame = Frame(frame)
canvas_frame.grid(row =0, column = 1)
#Application variables
self.char_pts = [(1,1),(7,1),(14,1),(1,7),(7,7),(14,7),(1,14),(7,14)
,(14,14)]
self.chars = []
self.text = []
self.tmpstr = '\nFor another,\nHit Randomize'
#Control FrameWidgets
self.lab = Label(control_frame, text=self.tmpstr)
self.lab.pack(side = TOP)
self.b1 = Button(control_frame, text='Randomize')
self.b1.config(command=self.randomize)
self.b1.pack()
# The Canvas
self.canvas = Canvas(canvas_frame, width = 800, height = 800)
self.canvas.config(bg='white')
self.canvas.pack()
frame.pack()
#Menu
menubar = Menu(root)
menu_1 = Menu(menubar, tearoff=0)
menu_1.add_command(label='Quit',command=root.destroy)
menubar.add_cascade(label='File', menu=menu_1)
master.config(menu=menubar)
self.randomize()
def randomize(self):
self.canvas.delete(ALL)
# create characters
self.chars = []
for j in range(10):
new_char = []
b = randint(0,8)
for i in range(randint(2,7)):
a = b
b = (a + randint(1,8))%9
new_char.append((a,b,randint(1,2)))
self.chars.append(new_char)
# create text, in 2-7 letter long words.
tl = 0
self.text = []
while tl <3000:
wl = randint(2,7)
for k in range(wl):
self.text.append(randint(1,len(self.chars)-1))
tl = tl + wl + 1
self.text.append(0)
# now write the text using the characters
i = 0
j = 0
for char in self.text:
if char != 0:
for seg in self.chars[char]:
start = seg[0]
end = seg[1]
wt = seg[2]
x1 = i*15+self.char_pts[start][0]
y1 = j*17+self.char_pts[start][1]
x2 = i*15+self.char_pts[end][0]
y2 = j*17+self.char_pts[end][1]
if x1==x2 or y1==y2:
self.canvas.create_line(x1,y1,x2,y2,width=wt)
else:
self.canvas.create_arc(x1,y1,x2,y1,width=wt)
if i == 50:
j = j + 1
i =0
else:
i= i + 1
self.canvas.update()
if __name__ == '__main__':
root = Tk()
root.wm_title('Alien Text')
app = App(root)
root.mainloop()
The Program
from tkinter import *
from random import randint
class App:
"""This class is derived, I think, from a TK class and is designed to
work with the TK environment.
Requires imports from Tkinter, math, and random"""
def __init__(self, master):
"""This class is the whole of the application """
# Necessary Frames
frame = Frame(master)
control_frame = Frame(frame)
control_frame.grid(row = 0, column = 0, sticky = N)
canvas_frame = Frame(frame)
canvas_frame.grid(row =0, column = 1)
#Application variables
self.char_pts = [(1,1),(7,1),(14,1),(1,7),(7,7),(14,7),(1,14),(7,14)
,(14,14)]
self.chars = []
self.text = []
self.tmpstr = '\nFor another,\nHit Randomize'
#Control FrameWidgets
self.lab = Label(control_frame, text=self.tmpstr)
self.lab.pack(side = TOP)
self.b1 = Button(control_frame, text='Randomize')
self.b1.config(command=self.randomize)
self.b1.pack()
# The Canvas
self.canvas = Canvas(canvas_frame, width = 800, height = 800)
self.canvas.config(bg='white')
self.canvas.pack()
frame.pack()
#Menu
menubar = Menu(root)
menu_1 = Menu(menubar, tearoff=0)
menu_1.add_command(label='Quit',command=root.destroy)
menubar.add_cascade(label='File', menu=menu_1)
master.config(menu=menubar)
self.randomize()
def randomize(self):
self.canvas.delete(ALL)
# create characters
self.chars = []
for j in range(10):
new_char = []
b = randint(0,8)
for i in range(randint(2,7)):
a = b
b = (a + randint(1,8))%9
new_char.append((a,b,randint(1,2)))
self.chars.append(new_char)
# create text, in 2-7 letter long words.
tl = 0
self.text = []
while tl <3000:
wl = randint(2,7)
for k in range(wl):
self.text.append(randint(1,len(self.chars)-1))
tl = tl + wl + 1
self.text.append(0)
# now write the text using the characters
i = 0
j = 0
for char in self.text:
if char != 0:
for seg in self.chars[char]:
start = seg[0]
end = seg[1]
wt = seg[2]
x1 = i*15+self.char_pts[start][0]
y1 = j*17+self.char_pts[start][1]
x2 = i*15+self.char_pts[end][0]
y2 = j*17+self.char_pts[end][1]
if x1==x2 or y1==y2:
self.canvas.create_line(x1,y1,x2,y2,width=wt)
else:
self.canvas.create_arc(x1,y1,x2,y1,width=wt)
if i == 50:
j = j + 1
i =0
else:
i= i + 1
self.canvas.update()
if __name__ == '__main__':
root = Tk()
root.wm_title('Alien Text')
app = App(root)
root.mainloop()
Thursday, April 9, 2020
About "random" numbers
It is an interesting thing that if you were to ask some person to give you a "random" 6-digit number, they would tend to try really hard to not repeat digits. People have a tendency to think that random number do not have repeating digits. But an analysis of these numbers shows that, in fact, for longer numbers, it starts to be more likely that there are repeated digits than not. Below is a table of the number of digits and the likelihood that there are repeating digits.
(argh, excuse me but there is not a control to create a table!!)
Number of digits vs. likelihood of repeated digits:
The math of permutations and combinations is explained here .
The python math module functions are explained here. The ones that are relevant are the factorial, comb and perm functions. I wrote some code to re-create these. I found out that after 10 levels of recursion, Python gives you an error message. So I had to use the math module version of the factorial function.
Also, if you don't believe the math, I also wrote a piece of code that does a brute force calculation. It does take some time to work its way through all the different combinations. And it will not give the exact same results since it is not considering the numbers that start with 0.
(argh, excuse me but there is not a control to create a table!!)
Number of digits vs. likelihood of repeated digits:
- None
- 9.99%
- 28%
- 50%
- 70%
- 85%
- 94%
- 98%
- 99%
- nearly 100%
The math of permutations and combinations is explained here .
The python math module functions are explained here. The ones that are relevant are the factorial, comb and perm functions. I wrote some code to re-create these. I found out that after 10 levels of recursion, Python gives you an error message. So I had to use the math module version of the factorial function.
# This defines the permutation function# and the combination functionfrom math import factorialdef perm(n,r):return factorial(n)/factorial(n-r)def comb(n,r):return factorial(n)/factorial(n-r)/factorial(r)for i in range(2,11):print(i,1-perm(10,i)/10**i)
Also, if you don't believe the math, I also wrote a piece of code that does a brute force calculation. It does take some time to work its way through all the different combinations. And it will not give the exact same results since it is not considering the numbers that start with 0.
# This program prints out how many of the numbers in a range
# have repeating digits
n = 2
flag = True
while flag:
test = 10**(n-1)
count = 0
print(test)
while test < 10**n:
a = str(test)
dupe = False
for i in range(10):
if a.count(str(i))>1:
dupe = True
if dupe:
count = count + 1
test = test +1
ratio = count / 10**n
print(n,count, ratio)
ask = input("continue? (n to end) >")
if ask == 'n':
flag = False
n = n+1So it's an interesting bit of psychology so I hope you enjoy it.
Subscribe to:
Posts (Atom)