Project management is not easy. A handfull of practical hints from ~20 years of experience:
Dont ask for more ressources. Ask for the ressources you were promised, but never got.
Dont ask for an extension on deadlines. Ask that the ones you got in the first place are not changed.
Never expect anyone to have heard of the iron triangle of project management.
Even if they actually have heard of it before.
Never expect anyone to have any understanding of what the project is about.
Even if they are in charge of managing it.
When, at the beginning of a project, estimations of the necessary ressources are deemed irrelevant by the steering commitee, buy antacids. You will get an ulcer.
When someone is given a budget – never expect them to stay within it.
Linux have a lot of small tools, that only does one thing. But do it really well (compare to Windows, that has a lot of large tools that does everything rather badly).
This is really just a note to myself. These tools are really useful but they are not (yet) second nature to me. I often find myself in the situation, where I know there is a tool for something, that I have used several times before. But simply can’t remember what it was.
grep. Searches files for lines matching a regular expression. Useful parameters (or at least parameters I have a regular use for):
-c returns a count of the lines matching.
-n returns the linenumber (in the file) of the matching line.
tail. returns the last part of a file
-n 6 returns the last 6 lines of the file (standard 10)
head. Returns the first part of a file
-n 6 returns the first 6 lines of the file (standard 10)
cut. Removes sections of lines in a file (or other input)
-d x. Splits the line at x. Use ‘ ‘ for space
-f 1. Select the first field.
wc. Counts stuff in files.
-l. counts the lines in the file (or other input)
-w count the words in the file (or other input)
|. Piping. Takes the result of the command in front of it, and pass it to the command after it (and that is the direction. If you find examples on Stackoverflow that will only give the desired result if the direction is reversed, don’t be surprised if it does not work…)
cat. Prints one or more files to standard output (your screen).
But if we print to another output, eg with “> file.name”, we can concatenate several files.
find. Searches for files. “find .” finds everything. Pipe it to grep to search for something specific. eg “find . | grep ‘acta'” to find all files containing the string “acta”.
-print prints the complete filename.
-print0 prints the complete filename even if it includes a newline.
By popular demand: Star Trek in stardate order. Discovery is not in the list. I think we still have to figure out if it is a heretical series, or if it fits into the correct, and only true timeline.
Series
Season
Title
Episode
(Star)date(s)
Stardate used for sorting
ENT
1
Broken Bow
1×01/02
4/16/2151
ENT
1
Fight or Flight
1×03
05-06-2151
ENT
1
Strange New World
1×04
Unknown
ENT
1
Unexpected
1×05
Unknown
ENT
1
Terra Nova
1×06
Unknown
ENT
1
The Andorian Incident
1×07
Unknown
ENT
1
Breaking the Ice
1×08
Unknown
ENT
1
Civilization
1×09
7/31/2151
ENT
1
Fortunate Son
1×10
Unknown
ENT
1
Silent Enemy
1×12
09-01-2151
ENT
1
Cold Front
1×11
09-09-2151
ENT
1
Dear Doctor
1×13
Unknown
ENT
1
Shadows of P’Jem
1×15
Unknown
ENT
1
Sleeping Dogs
1×14
Unknown
ENT
1
Shuttlepod One
1×16
11-09-2151
ENT
1
Fusion
1×17
Unknown
ENT
1
Rogue Planet
1×18
Unknown
ENT
1
Acquisition
1×19
Unknown
ENT
1
Oasis
1×20
Unknown
ENT
1
Detained
1×21
Unknown
ENT
1
Vox Sola
1×22
Unknown
ENT
1
Fallen Hero
1×23
02-09-2152
ENT
1
Desert Crossing
1×24
02-12-2152
ENT
1
Two Days and Two Nights
1×25
2/18/2152
ENT
1
Shockwave
1×26
Unknown
ENT
2
Shockwave, Part II
2×01
Unknown
ENT
2
Carbon Creek
2×02
04-12-2152
ENT
2
Minefield
2×03
Unknown
ENT
2
Dead Stop
2×04
Unknown
ENT
2
A Night in Sickbay
2×05
Unknown
ENT
2
Marauders
2×06
Unknown
ENT
2
The Seventh
2×07
Unknown
ENT
2
The Communicator
2×08
Unknown
ENT
2
Singularity
2×09
8/14/2152
ENT
2
Vanishing Point
2×10
Unknown
ENT
2
Precious Cargo
2×11
09-12-2152
ENT
2
The Catwalk
2×12
9/18/2152
ENT
2
Dawn
2×13
Unknown
ENT
2
Stigma
2×14
Unknown
ENT
2
Cease Fire
2×15
Unknown
ENT
2
Future Tense
2×16
Unknown
ENT
2
Canamar
2×17
Unknown
ENT
2
The Crossing
2×18
Unknown
ENT
2
Judgment
2×19
Unknown
ENT
2
Horizon
2×20
01-10-2153
ENT
2
The Breach
2×21
Unknown
ENT
2
Cogenitor
2×22
Unknown
ENT
2
Regeneration
2×23
03-01-2153
ENT
2
First Flight
2×24
Unknown
ENT
2
Bounty
2×25
3/21/2153
ENT
2
The Expanse
2×26
4/24/2153
ENT
3
The Xindi
3×01
Unknown
ENT
3
Anomaly
3×02
Unknown
ENT
3
Extinction
3×03
Unknown
ENT
3
Rajiin
3×04
Unknown
ENT
3
Impulse
3×05
Unknown
ENT
3
Exile
3×06
Unknown
ENT
3
The Shipment
3×07
Unknown
ENT
3
Twilight
3×08
Unknown
ENT
3
North Star
3×09
Unknown
ENT
3
Similitude
3×10
Unknown
ENT
3
Carpenter Street
3×11
Unknown
ENT
3
Chosen Realm
3×12
Unknown
ENT
3
Proving Ground
3×13
12-06-2153
ENT
3
Stratagem
3×14
12-12-2153
ENT
3
Harbinger
3×15
12/27/2153
ENT
3
Doctor’s Orders
3×16
Unknown
ENT
3
Azati Prime
3×18
2154-01
ENT
3
Hatchery
3×17
01-08-2154
ENT
3
Damage
3×19
Unknown
ENT
3
The Forgotten
3×20
Unknown
ENT
3
E²
3×21
Unknown
ENT
3
The Council
3×22
02-12-2154
ENT
3
Countdown
3×23
2/13/2154
ENT
3
Zero Hour
3×24
2/14/2154
ENT
4
Storm Front
4×01
Unknown
ENT
4
Storm Front, Part II
4×02
Unknown
ENT
4
Home
4×03
Unknown
ENT
4
Borderland
4×04
5/17/2154
ENT
4
Cold Station 12
4×05
Unknown
ENT
4
The Augments
4×06
5/27/2154
ENT
4
The Forge
4×07
Unknown
ENT
4
Awakening
4×08
Unknown
ENT
4
Kir’Shara
4×09
Unknown
ENT
4
Daedalus
4×10
Unknown
ENT
4
Observer Effect
4×11
Unknown
ENT
4
Babel One
4×12
11-12-2154
ENT
4
United
4×13
11/15/2154
ENT
4
The Aenar
4×14
Unknown
ENT
4
Affliction
4×15
11/27/2154
ENT
4
Divergence
4×16
2154-12
ENT
4
Bound
4×17
12/27/2154
ENT
4
In a Mirror, Darkly
4×18
1/13/2155
ENT
4
In a Mirror, Darkly, Part II
4×19
1/18/2155
ENT
4
Demons
4×20
1/19/2155
ENT
4
Terra Prime
4×21
Unknown
TOS
0
The Cage
0x01
TAS
1
The Magicks of Megas-Tu
1×08
1254.4
1254.4
TOS
1
Where No Man Has Gone Before
1×01
1312.4 – 1313.8
1312.4
TOS
1
Mudd’s Women
1×03
1329.8 – 1330.1
1329.8
TOS
1
The Corbomite Maneuver
1×02
1512.2 – 1514.1
1512.2
TOS
1
The Man Trap
1×05
1513.1 – 1513.8
1513.1
TOS
1
Charlie X
1×07
1533.6 – 1535.8
1533.6
TOS
1
The Enemy Within
1×04
1672.1 – 1673.1
1672.1
TOS
1
The Naked Time
1×06
1704.2 – 1704.4
1704.2
TOS
1
Balance of Terror
1×08
1709.2 – 1709.6
1709.2
TOS
1
The Squire of Gothos
1×18
2124.5 – 2126.3
2124.5
TOS
1
What Are Little Girls Made Of?
1×09
2712.4
2712.4
TOS
1
Miri
1×11
2713.5 – 2713.3
2713.5
TOS
1
Dagger of the Mind
1×10
2715.1 – 2715.2
2715.1
TOS
1
The Conscience of the King
1×12
2817.6 – 2819.8
2817.6
TOS
1
The Galileo Seven
1×13
2821.5 – 2823.8
2821.5
TOS
1
Court Martial
1×14
2947.3 – 2950.1
2947.3
TOS
1
The Menagerie, Part I
1×15
3012.4 – 3012.6
3012.4
TOS
1
The Menagerie, Part II
1×16
3013.1 – 3013.2
3013.1
TOS
2
Catspaw
2×01
3018.2
3018.2
TOS
1
Shore Leave
1×17
3025.3 – 3025.8
3025.3
TOS
1
Arena
1×19
3045.6 – 3046.2
3045.6
TOS
1
The Alternative Factor
1×20
3087.6 – 3088.7
3087.6
TOS
1
Tomorrow is Yesterday
1×21
3113.2 – 3114.1
3113.2
TOS
1
Space Seed
1×24
3141.9 – 3143.3
3141.9
TOS
1
The Return of the Archons
1×22
3156.2 – 3158.7
3156.2
TAS
2
The Practical Joker
2×03
3183.3
3183.3
TOS
1
A Taste of Armageddon
1×23
3192.1 – 3193.0
3192.1
TOS
1
The Devil in the Dark
1×26
3196.1
3196.1
TOS
1
Errand of Mercy
1×27
3198.4 – 3201.7
3198.4
TOS
2
The Gamesters of Triskelion
2×17
3211.7 – 3259.2
3211.7
TOS
2
Metamorphosis
2×02
3219.8 – 3220.3
3219.8
TOS
1
Operation — Annihilate!
1×29
3287.2 – 3289.8
3287.2
TOS
2
Amok Time
2×05
3372.7
3372.7
TOS
1
This Side of Paradise
1×25
3417.3 – 3417.7
3417.3
TOS
2
Who Mourns for Adonais?
2×04
3468.1
3468.1
TOS
2
The Deadly Years
2×11
3478.2 – 3479.4
3478.2
TOS
2
Friday’s Child
2×03
3497.2 – 3499.1
3497.2
TOS
2
The Changeling
2×08
3541.9
3541.9
TOS
2
Wolf in the Fold
2×07
3614.9 – 3615.4
3614.9
TOS
2
Obsession
2×18
3619.2 – 3620.7
3619.2
TOS
2
The Apple
2×09
3715.0 – 3715.6
3715
TOS
2
Journey to Babel
2×15
3842.3 – 3843.4
3842.3
TOS
2
Bread and Circuses
2×14
4040.7 – 4041.7
4040.7
TAS
1
The Slaver Weapon
1×14
4187.3
4187.3
TOS
2
The Doomsday Machine
2×06
4202.9
4202.9
TOS
2
A Private Little War
2×16
4211.4 – 4211.8
4211.4
TOS
2
The Immunity Syndrome
2×19
4307.1 – 4309.4
4307.1
TOS
3
Elaan of Troyius
3×02
4372.5
4372.5
TOS
3
Spectre of the Gun
3×01
4385.3
4385.3
TOS
2
I, Mudd
2×12
4513.3
4513.3
TOS
2
The Trouble with Tribbles
2×13
4523.3 – 4525.6
4523.3
DS9
5
Trials and Tribble-ations
5×06
4523.7
4523.7
TOS
2
By Any Other Name
2×21
4657.5 – 4658.9
4657.5
TOS
2
The Ultimate Computer
2×24
4729.4 – 4731.3
4729.4
TOS
2
Return to Tomorrow
2×22
4768.3 – 4770.3
4768.3
TOS
3
The Paradise Syndrome
3×03
4842.6 – 4843.6
4842.6
TAS
1
Mudd’s Passion
1×10
4978.5
4978.5
TOS
3
The Enterprise Incident
3×04
5027.3 – 5027.4
5027.3
TOS
3
And the Children Shall Lead
3×05
5029.5
5029.5
TOS
2
A Piece of the Action
2×20
Unknown
5101
TOS
2
Patterns of Force
2×23
Unknown
5102
TOS
2
The Omega Glory
2×25
5103
TOS
2
Assignment: Earth
2×26
Unknown
5104
TOS
1
The City on the Edge of Forever
1×28
Unknown
5105
TOS
2
Mirror, Mirror
2×10
Unknown
5106
TOS
3
Day of the Dove
3×11
Unknown
5108
TOS
3
That Which Survives
3×14
Unknown
5109
TOS
3
The Empath
3×08
5121.5
5121.5
TAS
1
The Survivor
1×06
5143.3
5143.3
TAS
1
Beyond the Farthest Star
1×01
5221.3 – 5221.8
5221.3
TAS
1
The Time Trap
1×12
5267.2 – 5267.6
5267.2
TAS
2
Albatross
2×04
5275.6 – 5276.8
5275.6
TAS
1
One of Our Planets Is Missing
1×03
5371.3 – 5372.1
5371.3
TAS
1
Yesteryear
1×02
5373.4
5373.4
TAS
1
More Tribbles, More Troubles
1×05
5392.4
5392.4
TOS
3
The Mark of Gideon
3×17
5423.4 – 5423.8
5423.4
TOS
3
Spock’s Brain
3×06
5431.4 – 5432.3
5431.4
TOS
3
For the World is Hollow and I Have Touched the Sky
I have a strange affinity for attractors, and has had it since graduating highschool, where I got a top grade in the final mathematics examination. That was under the old grading system. And the grade (13) was given to only two students in my high school that year. The examination centered on strange attractors. I’ve have not spend much time on it lateer. But there is a weird beauty in them.
Recently I discovered Clifford Attractors. Take a look at this page for some very nice examples. They look stunning, and are simple to handle. Lets play with them!
Clifford Attractors are defined by iteratively making these calculations: xn+1 <- sin(ayn) + ccos(axn) yn+1 <- sin(bxn) + dcos(b*yn)
Choose a, b, c and d between -2 and 2. Calculate x,y for n=0 to n=10.000.000 and plot them. It looks cool!
Lets begin by defining a function that takes four variables and a number of points, and calculate the points:
calcTrace <- function(a,b,c,d,numint){
x <- y <- rep(NULL, numint) # initializing the vectors
x[1] <- 0 # set the first point to (0,0)
y[1] <- 0
for (i in 2:numint){ # calculate the following points
x[i] <- sin(a*y[(i-1)]) + c*cos(a*x[(i-1)])
y[i] <- sin(b*x[(i-1)]) + d*cos(b*y[(i-1)])
}
df <- data.frame(x=x,y=y)
return(df)
}
Lets also define some parameters. I would prefer to choose the parameters at random. But there are a surprising number of instances where this lead to nothing. The formulas converges very quickly on just a few values, and I end up with a simple dot on the plot. I guess that is to be expected – but not what I am looking for. I want beautiful images!
a <- -1.8
b <- -1.9
c <- -1.7
d <- 1.9
points <- calcTrace(a,b,c,d,10000000)
That takes some time – I’ll get back to that. Lets plot it. I remove almost anything from the ggplot theme, and insert the parameters in the plot.
All right. It takes some time to do the calculations. There are ways to speed that up.
One way is to compile the function.
library(compiler)
compiled <- cmpfun(calcTrace)
According to the compiler packages, that should make the function faster. Lets test it:
library(microbenchmark)
test <- microbenchmark(
calcTrace(a,b,c,d,10000000),
compiled(a,b,c,d,10000000) , times=3
)
print(test)
I am not impressed. This result might be caused by the fact that I am running Paperclips http://www.decisionproblem.com/paperclips in the background (almost ready to release the hypnodrones!) on a not particularly powerfull laptop.
What else could be done? I’m tinkering with this to hone my R-skills. But here might be a situation where it would be better to do it in another language.
The library Rcpp allows me to add C++ code. Lets try that:
library(Rcpp)
cppFunction('DataFrame cppTrace(double a, double b, double c, double d, int numint) {
// create the columns
NumericVector x(numint);
NumericVector y(numint);
x[0]=0;
y[0]=0;
for(int i = 1; i < numint; ++i) {
x[i] = sin(a*y[i-1])+c*cos(a*x[i-1]);
y[i] = sin(b*x[i-1])+d*cos(b*y[i-1]);
}
// return a new data frame
return DataFrame::create(_["x"]= x, _["y"]= y);
}
')
I’ve recently been involved in the recruitment of a mid-level manager in an organization I’m involved with. That got me thinking (always a good way to prepare for anything):
What questions are reasonable to ask? There are rules of course, but what kind of questions is it OK for the prospective new employee to ask.
There are all the professional questions. But you should also be interested in what kind of a workplace you are potentially entering.
I think a good question is: What kind of employee benefits do you offer? And why those?
The added question is important. I am not interested in knowing that you offer all the fruit I can eat. That is not what will decide if I want to take the job.
But it does make a difference if company A offers free coffee. And company B offers me all the water and electricity I will need to brew coffee on the brewer I have to bring myself, using coffee grounds that I will have to buy myself.
And it would be interesting to hear a manager reflect on why they offer free yoga, coffee or whatever.
I think it says a lot about how employees are viewed in a company.
We celebrate Pi-day (3/14) every year at the library. And though it is december, and there is months to the big day, it is not too early to begin planning. This is something we do in the incredibly amounts of time we have left over when all the other tasks that also only take a tiny portion of the day are done. In other words, this is something we plan in our weekly lunchbreak.
Usually Henrik delivers a small talk about Pi. We eat some Pie, and there is much rejoicing.
But we would like to show something else. A cool visualization perhaps. There are several out there, but it is no fun just to show cool stuff. Its much cooler to understand how it is done.
One of the visualizaions we found on the net is this. https://www.visualcinnamon.com/portfolio/the-art-in-pi It is made by the extremely talented Nadieh Bremer. Take a look at her page. She does a lot of other cool stuff!
So. How to replicate this?
The idea is to take pi. Draw a line segment from 0,0 in the plane to a new point, determined by the first digit. Then we draw another segment from that point, to a newer point, determined by the second digit in Pi. Continue ad nauseam, or until your computer catches fire. Add colours, and make it look cool.
First item is to get pi to a million decimal places. Read it in, and make a vector containing all the digits. I’ll begin with a smaller string.
Not quite pi. But I can’t be bothered figuring out how many digits of pi I should use in order to get all the digits from 0 to 9. I want that to make sure that whatever I do, works on all the digits.
Next up is getting rid of the period.
numvec <- gsub("[[:punct:]]", "", testnumvec)
In Denmark we would use a “,” instead of “.” This removes all punctuation.
Now we convert it to a vector with individual digits. And cast them as integers rather than characters.
numvec <- as.integer(unlist(strsplit(numvec,"")))
We begin a (0,0). The next point is determined by the first digit i pi – 3. The number 3 should determine witch direction, angle, we should move. The new x-value will be cos(f(3)), where f(3) is some function, that converts 3 to the correct angle. That should be some fraction of pi. The new y-value is similarly determined by sin(f(3)).
What should f(x) be? Imagine a decimal clock, with the ten digits 0 to 9 positioned around the circle. In the original 0 is at top, at 12 o’clock. 5 is at 6 o’clock. And the numbers follow the circle clockwise. In the unity circle 0 is positioned at 1/2pi. 5 at 1 1/2 pi. So f(0)=1/2pi, f(5)=1 1/2pi.
This formula gives us the result we need: 5/2pi – z/5pi.
z is the digit in pi. For all of them, we can calculate the steps we need in this way:
x <- cos(5/2*pi - numvec/5*pi)
y <- sin(5/2*pi - numvec/5*pi)
So. Beginning at (x0,y0), we calculate the trig functions, add it to (x0,y0) and get (x1,y1). When we continue to do that, we notice, that xi is the cumulative sum of all the calculated x-values. If we calculate the trig functions for all of the digits in pi, and then calculate the cumulative sum, we get all the x-values. Similarly with all the y-values.
Thats neat, and thanks to Henrik, who pointed this out. We get the cumulative sums easily: And we can then get the cumulative sums with:
x <- cumsum(x)
y <- cumsum(y)
Thats it! There is just a little detail. The first value in x,y is the first step we need to take – or the second point if you will. We will need to add a 0 at the start:
x <- c(0,x)
y <- c(0,y)
Thats it! I should now be able to plot it. Lets just do a quick test:
plot(x,y, type="l")
That looks almost like what we need. The most notable difference is that Nadieh only plots the decimals. I include the “3” as well. We are going to test this, and it is cumbersome to do all the preceding steps. Let’s begin with defining the generation of points as a function, that takes a string. In just a little while I’ll invoke the magick of ggplot. So it would be convenient that the result is a dataframe:
piPoints <- function(piString){
numbers <- gsub("[[:punct:]]", "", piString)
numbers <- as.integer(unlist(strsplit(numbers,"")))
x <- cos(5/2*pi - numbers/5*pi)
y <- sin(5/2*pi - numbers/5*pi)
x <- cumsum(x)
y <- cumsum(y)
x <- c(0,x)
y <- c(0,y)
df <- data.frame(as.integer(c(0,numbers)),x,y)
colnames(df) <- c("num", "x", "y")
return(df)
}
All right. We now have a dataframe with three columns. The number, and the x,y coordinates. We can plot that with ggplot:
Weird. Something is wrong. Look at the second linesegment. It goes up and to the right, just as it should, since this segment represents a “1”. But the color? It is green. It should be sorta orangy. The reason is that ggplot looks at the number, and by implication the color, at the origin of the linesegment. Not at the end. How to change that? What I really need to do, is shifting the number column one place relative to the x,y pairs. Simply done – remove the 0 at the beginning of the num-vector in the function. And the final digits in the x and y vectors. I really don’t like it, as it increases the size of the dataframe – but I add an id-column as well. Just a sequential number, to control the colouring:
piPoints <- function(piString){
numbers <- gsub("[[:punct:]]", "", piString)
numbers <- as.integer(unlist(strsplit(numbers,"")))
x <- cos(5/2*pi - numbers/5*pi)
y <- sin(5/2*pi - numbers/5*pi)
x <- cumsum(x)
y <- cumsum(y)
x <- c(0,x)
y <- c(0,y)
id <- 1:(length(y)-1)
df <- data.frame(as.integer(c(numbers)),x[-length(x)],y[-length(y)], id)
colnames(df) <- c("num", "x", "y", "id")
return(df)
}
Lets beautify it at bit. theme_bw removes the horrible grey background. coord_fixed(ratio=1) controls the aspect-ratio of the plot. Not really necessary, but in just a short while I’ll expand to other numbers, and would like to compare stuff. And in theme() a lot of stuff is set to blank – we need a clean plot. Finally – or not quite, I change the colours. http://colorbrewer2.org/ helps with choosing colours. Its targeted at maps. But this is a kind of map. I am, more or less working with continous data. So instead of scale_colour_brewer, I use scale_colour_distiller. It’s not quite kosher to use a qualitative scale for this kind of data. But I like the colours, and I really need help choosing them, since I am not a talented designer.
## Warning: Using a discrete colour palette in a continuous scale.
## Consider using type = "seq" or type = "div" instead
Done!
Whats next?
So. I’ve done pi to a million decimal places. What about other fundamental mathematical constants?. Some of these perhaps? * Square root of 2 (Sqrt(2)) * Square root of 3 (Sqrt(3)) * Golden ratio * e * Natural logarithm of 2 (Log(2)) * Natural logarithm of 3 (Log(3)) * Natural logarithm of 10 (Log(10)) * Apéry’s constant (Zeta(3)) * Lemniscate constant (Lemniscate) * Catalan’s constant (Catalan) * Euler-Mascheroni constant (Euler’s Constant)
And why only a million places? Why not go to a billon?
I feel the need. The need for speed
This is the writeup. So I did all this, without looking at the original code. In the original, the cumulative sums are calculated differently:
x <- y <- rep(NULL, length(numvec))
x[1] <- 0
y[1] <- 0
for (i in 2:length(piVec)){
x[i] <- x[(i-1)] + sin((pi*2)*(numvec[i]/10))
y[i] <- y[(i-1)] + cos((pi*2)*(numvec[i]/10))
}
That is nice. It was also the way I tried to do it. I got lost in apply-functions using lag(). That was definitely not the way to do it.
But is my way faster? I would guess it is, as for-loops in general are not very fast in R. Guessing is not good enough, I need hard data. The way to get it is by measuring the time used. There are several tools for that, and I’ll use microbenchmark, since it provides a neat plot.
testnumvec <- read_file("pi_dec_1m.txt")
numbers <- gsub("[[:punct:]]", "", testnumvec)
numbers <- as.integer(unlist(strsplit(numbers,"")))
numvec <- numbers
mbm <- microbenchmark({
x <- cos(5/2*pi - numvec/5*pi)
y <- sin(5/2*pi - numvec/5*pi)
x <- cumsum(x)
y <- cumsum(y)
x <- c(0,x)
y <- c(0,y)
},{
x <- y <- rep(NULL, length(numvec))
x[1] <- 0
y[1] <- 0
for (i in 2:length(numvec)){
x[i] <- x[(i-1)] + sin((pi*2)*(numvec[i]/10))
y[i] <- y[(i-1)] + cos((pi*2)*(numvec[i]/10))
}
}, times=3
)
levels(mbm$expr) <- c("My way", "Original way")
mbm
## Unit: milliseconds
## expr min lq mean median uq max
## My way 177.0869 182.5159 189.8857 187.945 196.2851 204.6253
## Original way 1677.8690 1721.3408 1787.1957 1764.813 1841.8591 1918.9056
## neval cld
## 3 a
## 3 b
autoplot(mbm)
Thats kinda faster. Not that it makes that much of a difference – “My” method does the one million digits in 0.2 seconds. The original takes a little over 9 times as long. Who cares? You are only going to do it once. 2 seconds is not a problem. I would however like to make the same plot with a billion digits. I’m not sure I’ll even be able to plot it. But a naive guess implies that 1.000 times the number of digits will take 200 seconds, or a little more than 3 minutes to run through. 9 times that is almost half an hour. That is a difference you will notice.
The internet is really a cat-picture delivery system. One thing I have observed on twitter, is that images of cute kittens, in a library setting, receives a LOT of attention. Retweets, likes, all those endorphin inducing things.
Images of cute puppies give the same results. But I have the distinct impression, that people prefer cute kittens over puppies. That, however, is anecdotal evidence. Is there a way to measure it?
What we are interested in is the number of impressions. That is available from analytics.twitter.com. But-but-but. If the puppy-tweet is from november 1st and the kitten-tweet is from december 1st. And I am collecting the impressions on december 2nd, that wont give me a fair comparison. The puppy will have had far longer to collect impressions than the kitten. What I need, is to follow the interactions with the two tweets over time.
A problem with this is, that the twitter API does not give me access to those numbers. I will need another way to get them. I have written a Python script, that collect the csv-files from Twitter analytics for a number of months back. It can be found on my github page. Basically I use the Selenium package to let Python control a browser, that automagically download the statistics. If I do that once every hour, I will be able to graph the number of interactions over time.
I would like a rather comprehensive set of data. Not only kitties and puppies, but also cute hedgehodges, kangaroos etc. It would also be interesting to see if the time the tweet is made makes a difference. And just a single tweet of a cat is not a lot, there should probably be several tweets with each species. We are talking quite a lot of tweets. And quite a lot of data.
I am going to use a google spreadsheet as the backend. That will make it possible to graph the results as they come in.
One thing to consider working with Google Spreadsheets, is the inherent limitations. A workbook has an upper limit of 2.000.000 cells. I am going to gather rather a lot of data.
A quick back-of-envelope calculation:
Once every hour, I am going to download statistics for five months. I probably wont tweet more than 150 times pr month. And I am going to do this for three months, with an average of 30 days in each month. And 24 hours in every day. And for each tweet, I am going to collect 14 variables.
That results in: 14*24*30*3*150*5 = 22.680.000
A bit to much. How to reduce that? First of all, not every tweet I make will be relevant. I am still going to tweet about the benefits of reading instructions before deciding that you can’t figure out how to do something. If I only collect the tweets relevant to this study, it will greatly reduce the amount of data. In the above calculation I collect information on a total of 450 tweets. I will probably only need data on 30 tweets pr month. What also helps, is that the first day, I will get 24 data points on one tweet. On day two, I will get 24 datapoints on two tweets etc. That will probably save me.
The steps will be as follows:
Locate a suitable collection of images of cute animals in a library setting.
Plan when to tweet them – take into consideration the time of the tweets.
Collect – regularly – the data as pr the scripts mentioned above
Der har været nogen optællinger. Nu tæller vi ned. Der sker noget glædeligt. Noget er slut. Sådan ca. pr. midnat nytårsaften. Det sker noget andet. Det er ikke sikkert at det er bedre. Men dog er det en glædelig begivenhed.
If you get stressed to the point of spending time in the restroom crying, get help. Please. And do it now. Not a year after your call for help was ignored. Now. Right now.
Severe stress can lead to depressions. Stress in itself can be crippling. Depression is even worse.
Learn to recognize the signs. Not just in yourself. Also in your colleagues. If you are a manager it might be a good idea to learn about them as well.
And remember, it is not your fault that you get a stress induced depression. You may be expected to take the blame for being stressed. You may be expected to keep soldiering on until you break.