Woelcke Autark T5 Crosser Off Road

800 mile range
50 gallons water
Locking differential
~$3000 to ship to Halifax
7.5 foot width
Can navigate through 3 feet of water

Share

rethinkDB

This post will describe installation and interaction with rethinkDB using Javascript/Node.js. Ultimately I want to hook rethinkDB to Shiny. I am working on Debian/Jessie. Currently (August, 2017) rethinkDB will not install on Stretch.

Installation

1
2
3
4
#echo "deb http://download.rethinkdb.com/apt `lsb_release -cs` main" | tee /etc/apt/sources.list.d/rethinkdb.list
#wget -qO- https://download.rethinkdb.com/apt/pubkey.gpg | apt-key add -
#apt-get update
#apt-get install rethinkdb

Start the server with the command “rethinkdb” at a terminal prompt. By default administrative tools are available at localhost:8080/.

Client driver installation

cd to the working directory then install a node project

1
2
3
4
5
mbc@dc7700s: cd ./syncd/prog/shiny/music
mbc@dc7700s:~/syncd/prog/shiny/music$ npm init
mbc@dc7700s:~/syncd/prog/shiny/music$ npm install rethinkdb --save
mbc@dc7700s:~/syncd/prog/shiny/music$ node
>r = require('rethinkdb')

Set the conn variable and interact with the database

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
mbc@dc7700s:~/syncd/prog/shiny/music$ node
>r = require('rethinkdb')
>var connection = null;
r.connect( {host: 'localhost', port: 28015}, function(err, conn) {
if (err) throw err;
connection = conn;
})
>r.db('shiny').table('music').run(connection, function(err, cursor) {
if (err) throw err;
cursor.toArray(function(err, result) {
if (err) throw err;
console.log(JSON.stringify(result, null, 2));
});
});

Insert

1
2
3
4
5
6
7
8
r.db('shiny').table('music').insert([{artist:'Boston',
songs: [ {title:'song1',genre:'rock',url:'https://www.youtube.com/watch?v=SSR6ZzjDZ94'},
{title:'song2',genre:'rock',url:'https://www.youtube.com/watch?v=SSR6ZzjDZ94'}]
}]).run(connection, function(err, result) {
if (err) throw err;
console.log(JSON.stringify(result, null, 2));
})

Update

1
2
3
4
5
6
7
8
9
r.db('shiny').table('music').
filter(r.row("artist").eq("Boston")).
update({songs:
[ {title:'song1',genre:'rock',url:'https://www.youtube.com/watch?v=SSR6ZzjDZ94'},
{title:'song2',genre:'rock',url:'https://www.youtube.com/watch?v=SSR6ZzjDZ94'},
{title:'song3',genre:'rock',url:'https://www.youtube.com/watch?v=SSR6ZzjDZ94'}]}).run(connection, function(err, result) {
if (err) throw err;
console.log(JSON.stringify(result, null, 2));})

Show all

1
2
3
r.db('shiny').table('music').distinct().run(connection, function(err, result) {
if (err) throw err;
console.log(JSON.stringify(result, null, 2));})

Delete all

1
2
3
r.db('shiny').table('music').delete().run(connection, function(err, result) {
if (err) throw err;
console.log(JSON.stringify(result, null, 2));})

Launch script

The ‘launch.browser’ option to runApp() deals with the random port assigned by Shiny.

music.sh
1
2
3
4
5
#!/bin/bash
rethinkdb -d /home/mbc/shiny/music/rethinkdb_data/ &
R -e "shiny::runApp(appDir='/home/mbc/shiny/music', launch.browser=TRUE)"
Share

Fermi's Paradox

Aestivation: Aliens are hibernating until the average temperature of the universe cools a bit more which will make their information processing more efficient.

Share

Behavioral Genetics

Five laws from JayMan

Share

Coefficient of Relationship

i.b.d.: identical by descent

Consider relatives A and B

What is the probability that for any gene the alleles are i.b.d.?

Probability # identical
$c_2$ both
$c_1$ one
$c_0$ neither

$c_2 + c_1 + c_0 = 1$

$a= 1 + \delta a + e$

From Haldan and Jayacar(1962) tables of r (coefficient of relationship) are presented.

Relation Symbol Converse f F $\phi_{11}$ $\phi_{12}$ $\phi_{21}$ $\phi_{22}$ $\Phi$
Degree 1
Parent Child $\frac{1}{4}$ 0 0 $\frac{1}{2}$ $\frac{1}{2}$ $\frac{1}{4}$ 0
Degree 2
Mother’s Parent Daughter’s Child $\frac{1}{8}$ 0 $\frac{1}{2}$ $\frac{1}{4}$ $\frac{1}{4}$ $\frac{1}{8}$ 0
Father’s Parent Son’s Child $\frac{1}{8}$ 0 0 0 0 $\frac{1}{4}$ 0
Maternal half sib W S $\frac{1}{8}$ 0 $\frac{1}{2}$ $\frac{1}{4}$ $\frac{1}{4}$ $\frac{1}{8}$ 0
Paternal half sib H S $\frac{1}{8}$ 0 0 0 0 $\frac{1}{4}$ 0
Full sib M S $\frac{1}{4}$ $\frac{1}{4}$ $\frac{1}{2}$ $\frac{1}{4}$ $\frac{1}{4}$ $\frac{3}{8}$ $\frac{1}{2}$
Share

Overpopulation

White men can now tell black woman to stop having so many babies.

Share

Religion

Wealthy widows, the Catholic church, and individualism.

Share

Trees

100_1431.JPG

Urban Tree Database

i-Tree

NY Census

Share

Fertility

“Demography is destiny” or “it’s all about reproduction”.

World’s most important graph according to Steve Sailer:

un_population_projections.png

Sub Saharan Africa growth projected to double from 1.1 billion in 2013 to 2.4 billion in 2050 according to the Population Reference Bureau

It’s not just number of children per woman that is often referenced, but generation time, mortality, and even levels of altruism within a hosting population.

Let’s write a shiny app that will allow us to gain some insight by manipulating the relevant variables. The equations useful for estimates can be found in your population genetics textbook. I will use a simplified method of calculating population growth outlined by Wahl and DeHaan (2004). This simplified model will ignore complicating variables such as birth of males, gestation time and staggered births. Essentially I will be treating humans as dividing bacteria. Though a simplified model, you can still gain a sense of the synergism between generation time and fecundity.

In this model, the number of offspring N after some number of generations G given fecundtity (number of offspring per woman) F is:

$$N=F^G$$

I will fix the starting populations at 10 and perform calculations for 200 years, enough to get a feel for what our grandchildren might experience.

1
t <- seq(20, 200, by=20) ##t is in years

t (time in years) will serve as the abcissa of my plot.

The terminology I will use in the app is “Host” (suffix h; also called population 1, or p1) for the population accepting immigrants, and “Invaders” (suffix i; population 2 or p2) as the population of immigrants. To build your mental model, consider the host country something like America, and the immigrant source country some subsaharan country unconcerned with population growth and unaware of the concept of limited resources.

The growth equations:

1
2
x.h <- p1f^(t/p1g)
x.i <- p2f^(t/p2g)

p1f (fecundity) and p1g (generation time) hold input from the sliders. Consider the power t/p1g. If t is 20 years, and the input p1g is 20 years, 20/20 = 1 generation.

Next set up the plot. As it is difficult to get a sense of the magnitude of the differences generated with slider input, I want to calculate the difference in population size after 200 years and print that as annotation on the plot.

1
2
3
4
5
6
7
8
9
delta <- format(abs( x.h[10] - x.i[10] ), scientific=TRUE, digits=3)
ycoord <- 0.5*(max(x.h[10], x.i[10]))
ycoord2 <- 0.2*(max(x.h[10], x.i[10]))
xcoord <- 170
d <- data.frame(cbind(t, x.h, x.i))
ggplot(d, aes(t, x.h)) + geom_point( aes(size=3)) + labs(title="Fecundity X Generation Time") + geom_point(data=d, aes(t, x.i, col="red", size=3)) + annotate("text", x = xcoord, y = ycoord, label = paste("Difference after 200 years = ", delta, sep="")) + scale_y_log10() + theme(legend.position="none") + xlab("Years") + ylab("Population Size")

Consider a mixed population with equal numbers of Hosts and Invaders (10 each) after 200 years with equal fecundity (2) and a generation time of 20 years for the host, 15 years for the invaders. After 200 years the invaders outnumber hosts 10:1. It’s all downhill from there.

The app is hosted at shinyapps.io

Code is available on github

Share