Saturday, September 30, 2017

Making Turtle pictures with Numbers made from Numbers

The post Random Walks with Number Digits looked at pictures made from the digits of numbers. Go through each digit in turn. If it is 0 take a step to the right. If it is one go 36 degrees down from that. If it is 2 72 degrees etc etc. For base ten numbers this makes a picture that looks like brownian motion but with only 10 directions not any possible direction.

In this post I look at numbers made from numbers.

The Copeland–Erdős constant is made by sticking together all the prime numbers into a number 2 then 3 then 5 then 7 then 11 etc.. 0.235711131719232931374143 A033308. One of these turtle logo pictures made from this number has a very odd pattern. With 1.5 million digits from prime numbers this pattern is made. The Copeland–Erdős constant is normal so I would expect the loop to eventually come back around.

Champernowne constant is made with 1 then 2 then 3 then 4 etc.. 0.12345678910111213141516 makes a similar picture but it is much more curvy. 600k digits looks like

Thursday, September 28, 2017

Random Walks with Number Digits

Say you took each digit of a number and used that to decide which direction to take a step. What path would you follow?

Similar to last post I took Pi, e, Sqrt(2) and random numbers. I multiplied each digit by 36. There are 10 digits to go into the 360 degrees you can go. For 0 step right. For 1 36 degrees down from 0. For 2 72 degrees etc.

Here are the pictures with a description of which number made each at the end. If any look different that might be an indication the digits are not that random.

.

After drawing this I realised it looked like Dragon Curves. Googling Pi pictures and Golden curves revealed this book. so someone had the idea before.

My code for all these pictures is here. The picture is on reddit and people seemed to like it.

And now other numbers

E first 700k

e next million

Sqrt(2)

Using a random number generator, just for comparison

Catalan Constant

These look like pictures of brownian motion which in effect they are.

Wednesday, September 27, 2017

Pi Digits High Low Game

Suppose you take a long number and for each digit if it is bigger then the previous one increase a counter by one. If it is less then the previous number reduce the counter by one. You keep a running total and graph that total. Noting when it passes 0. This total number will go up and down and can get to zero many times. If you play this game with random numbers in a million digits on average the number of times you will have crossed 0 is 1594.4 and the standard deviation of the number of times crossed 0 is 1207.3. Though as the number of times zero is crossed cannot be less then 0 this is a bit odd.
       
import random

numcrossed=[]
j=0
while j < 200:
	i = 0
	last=0
	total=0
	x=[]
	y=[]
	crossed=0
	while i < 1000000:
		ran= random.randint(0, 10)
		if ran==last:
			total=total
		elif ran>last:
			total=total+1
		else:
			total=total-1
		if total==0:
			x.append(i)
			y.append(total)
			crossed=crossed+1        
		i=i+1        
		last=ran
	numcrossed.append(crossed)
	j=j+1
       
 
If instead of random numbers the digits of pi are used. This is what the path of total counts looks like
       
file = open("pi1000000.txt", "r") 
#3.14159265358979323846264338327950 pi2.txt
x = []
y = []
text=file.read() 

pi = list(text)
total =0
i = 0
crossed=0
i=0

while i < len(pi):
	if pi[i]>pi[i-1]:
		#print(pi[i])
		total=total+1
	if pi[i]
 

Pi has a 0 total 657 times. Which is more than 51 out of 200 random million long sequences did in my tests. None of this means anything. Going up or down based on digits in a base ten number but i like these pattern sort of sequences.

E crosses 0 1725 times

sqrt2 crosses 0 1300 times

and with 2 million digits


The python code for visualisation is 
       
import numpy as np
import matplotlib.pyplot as plt

plt.scatter(x, y, alpha=0.5, color='green')
plt.title('Sqrt 2 High Low Game')
plt.show()
       
 

Friday, April 07, 2017

Your child will live in your car parking space

When autonomous cars become mainstream what will happen to our parking spaces? Most experts think car ownership will become rare when autonomous cars exist.

How driverless cars will change car ownership forever

So Who’s Really Going to Own Autonomous Cars? There’s Four Scenarios.

Most of our houses have parking for two cars outside them. What will we do with these existing spaces then?

1. Rent the spaces out to autonomous cars. Some will do this but their ability to be used more of the time and to park themselves densely in unpopulated areas means we might have better use for the space.

2. More garden.

3. New houses. My two car spaces take up 25 square meters. Which is twice the size of this tiny house.

Or 25m squared is half the floor space of my actual house. And of this Ikea house.

These houses are cheap and I doubt people will be too bothered by having one replace the parking spaces behind their house.

People having a small house at the end of their garden might be already happening. For example this article Why An Increasing Number Of Americans Want To Build A Granny Flat. Explains why more people are already building houses beside their current one. Both young adult children and aging parents might find these small houses preferable to the alternatives. With young people increasingly living at home at an older age and seeming to have higher debts for worse job prospects a granny flat becomes more attractive.

It is possible autonomous cars will end up meaning people live in bigger houses further out of the city. But as a way to retrofit current housing car space houses will be popular.

But if all these car parking spaces become free. And you share with your neighbour enough space build a house the same size as yours. There will be some people who try and build new housing there.

Thursday, April 06, 2017

Will Automation Related Job Losses Increase?

"The consultancy firm PricewaterhouseCooper is predicting that the U.K. will lose 30 percent of its jobs to automation in the next 15 years. Automation is a global issue, and some countries are considering Universal Basic Income as a means of counteracting its associated job loses"

Is this more job losses than the usual trend? As in what is the average rate of job losses over 15 years?

Farming used to be the vast majority of workers 200 years ago. Farming underwent four and a bit halvings of the workforce percentage between 1900 and 2000.

In pure raw numbers there were 11.6 million farmers in 1900. 6 million in 1960. And 3.2 million today. In this time the population went from 76 million to 320.

In raw number terms employment in Agriculture dropped -0.65% a year when population was growing 2.8% a year.

So that's a bit over .65% of farm workers a year leave the sector. Not move from horse powering job to tractor pulling job but leave agriculture. So loss of individual agriculture job has been well over .65% per year for 100 years.

Over the 100 years agriculture was mechanised, refrigerated, nitrogen fertilised, pesticised, green revolutioned, factory farmed and GMOed. A lot happened.

To lose 30% of jobs in 15 years 2.35% of the jobs would have to lost each year.

That projected rate of job losses does seem to be a good bit higher than the loss for agriculture for last 100 years.

Wednesday, April 05, 2017

The smallest tool we use

What is the smallest individual object most people handle most days?

I think it probably used to be a match. But people do not use them as much anymore.

It could well be coins. The removal of 1 and 2 cent coins have increased the size of the smallest coin we use. The 5 cent weights 3.92g the 1 cent weighed 2.30g. And the increased use of cards and phone payment means coins seem to be on the way out.

It could well be a hairclip, though I am not sure how close they come to the majority of people using them.

.

Pills could well be the answer. It seems reasonable that close to the majority of people in the western world take a pill every day.

Are the tools we use getting larger over time? Smartphones have replaced big tools like walkmen and cameras for many of us. But maybe in some way they have also replaced small tools like coins and matches?

Tuesday, January 24, 2017

Elvis and Vaccines

‘I want to remain apolitical because I don’t think it’s right for me to use my celebrity and fame to persuade other people' Elvis quoted in this piece by Piers Morgan
Elvis is credited with saving thousands of lives by helping to advertise the new Salk Polio vaccine

It could be argued that vaccinations are medical and scientific and not political. But if you argue this you can't then bring science and vaccines into politics.

Thursday, January 19, 2017

Measures for a successful Trump

What falsifiable metric could be used to say Trump was successful by his own and by Republican aims?
Things he claims
1. Better healthcare. Cover Everybody, cost less and have lower deducables
2. More GDP Growth. Obama never had a year of 3% economic growth. "Obama is the first president in modern history not to have a single year of 3 percent growth. If Trump can deliver an average of more than 3% over his 4 years in office I think an impartial observer would agree the economy has done well.
3. A balanced Budget.
4. Infrastructure improvements are a big part of Trumps promise. These are measured here

Carbon emissions I would like to see improve or not get worse but Trump did not campaign on improving. If Carbon emissions increase as predicted Trump is only doing something he has campaigned on doing.

There are many things like this but by picking a small number of things that they claim will improve I want to make a easy to check test.

Trump and the Republican party aim to deliver 3%+ Growth. A healthcare plan that covers more people and reduces deductibles. Improved infrastructure. And a budget position that is improving. If they do not do this by their own terms they have not succeeded.

Immigration and Birthrate

"Let’s talk about the link between immigration and low reproduction rates"
This is a really weird article. It talks about how below replacement birth rates mean the population will decline. Which is true by definition.
Then about how some countries have lots of immigrants. Then it does nothing to link the two. So in spite of asking to talk about the link it doesn't.


I wanted to look first to see if there was a link. As the article does nothing to show there is.
I took a list of countries by their percentage of immigrants
And one of countries by their birthrate
I created this combined dataset of Country, Birthrate and Immigrant % and put it here

The correlation between birthrate and the percentage of immigrants in a country is weak.

> cor(data$FertilityRate, data$ImmigrantPer)
[1] -0.3463663
I am willing to bet you at odds that the correlation between wealth and birth rate and between wealth and % of immigrants is higher. That having money causes immigrants to come to your country and you to have less children. Not that people choose between having a child and a 25 year old Ethiopian.

So Irish Times please do talk about what is at best a weak link between immigration and low reproductive rates.

Wednesday, January 18, 2017

Brexit 12 objectives

These are the 12 objectives for Britain’s Brexit negotiations, as set out in prime minister Theresa May

Issues Brexiters really care about and will likely get
2. Control of our own laws
5. Control of immigration. Net migration seems to now be about 300k to the UK each year. The Tories promised to bring it below 100K. If immigration drops below 100k that probably means the people who voted to leave the EU have the immigration control they want.

Things that are not measurable
1. Certainty wherever possible
11. Co-operation on crime, terrorism and foreign affairs
12. A phased approach, delivering a smooth, orderly Brexit

Things they had before Brexit
4. Maintaining the common travel area with Ireland
6. Rights for EU nationals in Britain and British nationals in the EU
8. Free trade with European markets

Measurable things (I think they won't get)
3. Strengthening the United Kingdom
7. Enhancing rights for workers
9. New trade agreements with other countries. This probably breaks down to improved economy. So measures of the economic trade could be used to measure this one.
10. A leading role in science and innovation

I am willing to pick measurable metrics on these last four. % of people in Scotland who want independance. Where UK stands in global metrics of workers rights. Patents or and journal paper outputs and their are other metrics of countries innovation. University league tables are another possible metric for example.

Trade agreements are mainly about the economy. Inflation, consumer debt, Sterlings value, GDP growth, export growth are all useful metrics.


I can't think of an obvious metric that shows making your own laws in Parliament has been a good idea. But there are 8 other objectives May wants that are measurable. And general economic metrics most people accept as important.


With at least 10 things to measure to decide if Brexit is going well or badly I think it is reasonable for Leavers and Remainers to define what they would see as success for Brexit. This wont take into account big downside economic or military risks. Or peoples happiness at increased national sovereignty, though national happiness metrics might work.
But you can measure some things people say are important so why not define metrics of what would mean Brexit was a success?

Friday, January 13, 2017

Irish Election Spending 2016

In the Irish election 2016 who paid the most for each vote and for each seat?
8394832.89 total spending (report here) Electorate: 3305110 so €2.50 was spent on each vote. That is under half what is spend on a US presidential vote.
On a per seat and per vote basis

And on a Per Seat Basis


Party,"Votes,1st pref.",Seats,Spending
Fine Gael,544140,50,2768881.50
Fianna Fáil,519356,44,1687916.29
Sinn Féin,295319,23,650190.38
Labour Party,140898,7,1083718.38
AAA–PBP,84168,6,266942.48
Ind 4 Change,31365,4,51669.18
Social Dem,64094,3,190586.93
Green Party,57999,2,146792.27
and the r package code is

data <-  read.csv("spending.csv", header=TRUE)
datat <- mutate(data, perV = Spending/Votes.1st.pref., perS= Spending/Seats)

q<-  ggplot(data=datat, aes(x=Party, y=perV, fill=Party)) + geom_bar(stat="identity") +      scale_fill_manual(values=c("#E5E500", "#66BB66", "#6699FF", "#99CC33", "#FFC0CB","#CC0000", "#008800", "#752F8B"))
q <-q + theme(axis.text.x = element_text(angle = 90, hjust = 1))
q <-q + theme(legend.position="none")
q <-q + labs(title = "General Election Spending 2016")
q <-q + labs(y = "Euros Per Vote")

q<-  ggplot(data=datat, aes(x=Party, y=perS, fill=Party)) + geom_bar(stat="identity") +      scale_fill_manual(values=c("#E5E500", "#66BB66", "#6699FF", "#99CC33", "#FFC0CB","#CC0000", "#008800", "#752F8B"))
q <-q + theme(axis.text.x = element_text(angle = 90, hjust = 1))
q <-q + theme(legend.position="none")
q <-q + labs(title = "General Election Spending 2016")
q <-q + labs(y = "Euros Per Seat")




Wednesday, June 01, 2016

The Name of the Youngest Ever Modern Olympics Gold Medal Winner is Unknown

In the 1900 Olympics the Dutch rowing team were short a cox. They used a rower in the semifinal, Hermanus Brockmann, but decided his 60kg weight was too much of a handicap.

So the rowers, Françoise Brandt and Roelof Klein, picked a ten year old French boy (25kg) out of the crowd and asked him to cox for them.

They won the gold. And took a photo with the boy. But his identity has never been established.

Thursday, May 19, 2016

Dying at Work in the US

Dataset from the Occupational Safety & Health Administration, OHSA, track workplace fatalities in the US. They have CSVs records of the workplace deaths a year in the US, that they release publicly.

The data contains the date, location and a description for 4000 fatalities over five years. I created columns for state, zipcode, number of people and cause.

The most common interesting words in these descriptions are

  • 813 fell
  • 708 struck
  • 642 truck
  • 452 falling
  • 382 crushed
  • 352 head
  • 263 roof
  • 261 tree
  • 258 electrocuted
  • 244 ladder
  • 238 vehicle
  • 226 trailer
  • 197 machine
  • 186 collapsed
  • 180 forklift

Not common but interesting

  • 10 lightning
  • 48 shot
  • 4 dog
  • 2 bees

and here is a map I made of the states where they happen

I have created a repository to try augment the OSHA data and clean it up when errors are found.

The repository is on github here.

If you use it I'll give you edit rights and you can help improve it

Sunday, May 15, 2016

Handpicked by amazon

Whenever I check some product on Amazon for the next few days I get the product in the advertisements on Facebook

Handpicked?

Why would Amazon lie like this?

Thursday, April 21, 2016

Can you Judge a Book by its Cover?

"they've all got the same covers, and I thought they were all o' one sample, as you may say. But it seems one mustn't judge by th' outside. This is a puzzlin' world." The Mill on the Floss by George Eliot
What is the correlation between peoples ratings of a books cover and the ratings the book receives? This post is about a game devised to get people to rate book covers and gives some great visualisations comparing a books goodreads rating to its cover rating. They gathered over 3 million ratings of 100 covers.

I took their data and got the average rating for each of the covers they tested. I then scraped these 100 books Goodreads average ratings, number of ratings and number of reviews. The Data table and the code I used to scrape and aggregate is here. There are all sorts of accuracy warnings you can imagine around these results. The main ones being that the books and their covers all look pretty good to me. They are not on the self published fan fiction end of the market. The variables here are. num_ratings: Number of Goodreads ratings. rating: average rating of the book. num_reviews: Number of people who have actually written a review. cover_rating: The average rating people gave the cover of the book.

> cor(rating,cover_rating)

[1] 0.1609114

> cor(num_ratings,num_reviews)

[1] 0.9597442

> cor(rating,num_ratings)

[1] 0.2141307

> cor(rating,num_reviews)

[1] 0.2658916

> cor(num_ratings,cover_rating)

[1] 0.3059627

> cor(num_reviews,cover_rating)

[1] 0.3307553

So no you can't judge a book by its cover the correlation in ratings is only .16. You can guess the number of ratings by the number of reviews. You can't guess how highly rated a book is by the number of ratings. Having a good cover might increase the number of reviews your book gets by a bit.

The conclusion is you shouldn't judge a book by its cover. Or by its number of sales (ratings). But people probably do judge books by their cover a bit.

Monday, March 07, 2016

Maps to hide places

Logaskino was a military base in Siberia. Over 30 years Soviet mapmakers moved it around maps to throw off enemies "How to lie with maps" talks about how the Soviets would move around the location of military bases on maps. These maps show one small base (now abandoned) and the local river and how it moved around on maps over 30 years in order to attempt to confuse enemies

Friday, January 22, 2016

England's Temperature in 2015

Nine days in 2015 were the hottest for that day of the year since 1772. This compares to three in 2014, though 2014 had a hotter average temperature and was the hottest year on record in the UK.

England has a collected data on daily temperature from 1772 in the Hadley Centre Central England Temperature (HadCET) dataset.

I downloaded this Hadley Centre dataset. And I followed this tutorial. Based on an original graphic by Tufte.


Here the black line is the average temerature for each day last year. The dark line in the middle is the average average temperature (95% confidence). the staw coloured bigger lines represent the highest and lowest average daily temperature ever recorded on that day since 1772. the red dots are the days in 2015 that were hotter than any other day at that time of year since 1772.

Looking at the black line that represents last years temperatures it was the Winter and Autumn that were far above average. Instead of a scorching hot summer most of the record hot days were in November and December. 2014 had the same pattern of a hot Winter. No day in 2015 was the coldest for that date in the recorded time.

Sunday, January 17, 2016

In 2100 there will be a kilometer tall building

I was in the Burj Khalifa last week. It is very big. But when will some bigger building be built? I want to look at the building height trend to see what the trend line says. Talking the wikipedia page on the Tallest Building. There are two eras shown. The religious era (1200-1901) and the Skyscraper era. I put the data in a csv here.

The Correlation here is cor(Year,Height) [1] 0.39831 which isn't much. Basically Cathedral's burned down and were replaced by a similar sized world's tallest building from 1200 until 1900.

Looking just at the Skyscraper era 1884 on. cor(Year,Height) [1] 0.9340458 which really looks like height increases by follow time. Running this as a linear regression the Kilometer tall bulding is not expected until the end of the century

linearModelVar <- lm(Height ~ Year, newdata)

linearModelVar$coefficients[[2]]*2010+linearModelVar$coefficients[[1]]

646.6246 The Burj Khalifa was much taller than any building was expected to be in 2010

linearModelVar$coefficients[[2]]*2099+linearModelVar$coefficients[[1]]

1002.799 finally a kilometer tall building in 2099

linearModelVar$coefficients[[2]]*2241+linearModelVar$coefficients[[1]]

1604.903 a Mile high tower 2241 far into the future?

Saturday, January 16, 2016

Is Netflix making us smarter?

Vox has an article that mentions the artistic benefits of on demand TV viewing
The first factor was the rise of the DVR, which has made it cheaper and easier than ever before for people to record their favorite shows and watch them at their leisure. This has been great for television artistically, since it means creators can now more readily assume that every single episode of their show will be consumed in sequence.

Stephen Johnson's book "Everything Bad Is Good For You" analyses the complexity of TV programs from the 1970s and today and shows how much more complex modern ones are. Compare Columbo with one murderer shown at the start and it takes 70 minutes for them to be found out. Whereas a more modern CSI is 43 min of multiple plots with loads of characters.

The Vox piece points out that episodic series like CSI with few series long story arcs now seem outdated. Viewers are expected to keep information about longer plots now. Meaning there are more details about the characters and their relationships viewers need to track. Series you can play back at any time may be cognitively as well as artistically beneficial.

Tuesday, December 01, 2015

Tiny Bits of Land People Fight Over #1 Rockall

People will fight over any bit of land. "Rockall is about 25 metres (80 ft) wide and 31 metres (100 ft) long at its base[24] and rises sheer to a height of 17.15 m (56.27 ft)" from wikipedia.

A probably fake photo from 1974 of HMS Tartar's trip there. 'A sentry-box was constructed on Hall's Ledge, with two marines in full ceremonial uniform posted alongside, and the Union Flag was hoisted above.'

Every now and again Britain lands some people on this lump and takes a photo to prove it is theres. 'Former SAS member and survival expert Tom McClean lived on the island from 26 May 1985 to 4 July 1985 to affirm the UK's claim to the island'. Waves roll over the island so he had to hide in a bolted down giant coffin for the duration.


They do this partly because owning the Falklands isn't grim enough for them. And partly for all the oil and gas and such that might be between Rockall and Ireland.