The Hope -- MathPsych2017
Bayesian estimation using Drake equation
to meet our possible girlfriends in London


Authors Information

Mr. Unadon
26 years old ・ Unmarried ・ Looking for a lover
Future: Data Science?
MA(Psychology), Certificate of licensed cook,
Best award: A marketing analysis contest 2016
Unadon: MacOS Sierra10.12.1; Rversion3.3.2; rstan2.10.1
Contact : whitesnow1751★

23 years old ・ Unmarried ・ Seeking lovers
BD(Human Science), Psychometrics, Master Course
Best Award: A marketing analysis contest 2016
Academic award: The correction of respondent bias
Contact(Twitter): dastatis

dastatis: Windows10; Rversion3.3.3; rstan2.14.1


Let our english mistake excuse, please.
We are not good at english.

logo.jpg Unadon
This year's Mathematical Psychology seems to be held in UK!!
Let's Go Coventry! Warwick University!!
I'd like to go to London and party with a beautiful wome....
I want to learn cutting-edge Bayesian statistics!!!

dastatis hojo.png
UK is nice.
Of course, I plan to participate in MathPsych2017.
And, I wanna go drinking with girls in London.
And, I would like to go to London to see the famous universities.

logo.jpg Unadon
Let's join the conference seriously.
But I hope.
If I could go to London,
I feel like I can meet a my future girlfriend!

dastatis hojo.png
You noticed?
There is no such thing...
I also want to meet my future girlfriend,
but the probability of meeting
a possible girl friend in London will be... ZERO.

logo.jpg Unadon
Do you really think so?
Have a dream, dastatis.
Let's try to estimate the probability of
meeting our future girlfriend in London with Bayesian Modeling.
The Drake Equation will surely give us a hope ... maybe...

 The Drake Equation

dastatis hojo.png
Mr.Unadon, what is the Drake Equation?
...Oh, This is the wonderful equation!
It can estimate the number of
extraterrestrial intelligent life.

logo.jpg Unadon
That's right, dastatis. 
And Mr.Peter applied this equation to estimate
the number of "Possible Girlfriend" in London.

dastatis hojo.png
To caliculate "Possible Girlfriend",
Mr.Peter gave some constants below.
Popularion in UK (N*),
Rate of female(fw),
Rate of Londoners(fL)...and so on.(equation2)。
DrakeEquationPeter.png(equtaion 2)

logo.jpg Unadon
Good, but I think these cannot be constants.
These are stochastic variable because
the population of London changes daily.
And other parameters will be also the stochastic varible, such as
the rate of our favorite age group(fA),
the rate of university graduates(fU)
and the rate of attractive woman(fB).

dastatis hojo.png
So you assume the probability distribution for
estimating the parameter of "Population in UK", right?
You are a bayesian! I am a bayesian!
Unknown is parameter.

logo.jpg Unadon
Yes, our "possible girkfriends" will be defined as
a deterministic parameter!

dastatis hojo.png
Now write a new Drake equation that defines
the number of the "possible girlfriend", please❤❤

logo.jpg Unadon
OK, leave it to me(*´Д`)
OurDrakeEquation2.png (equation 3)

dastatis hojo.png
(Yes... I know why we do not have a girlfriend...)

Data collection

dastatis hojo.png
Mr.Unadon, how many people do you like? Choose the girls below pictures, please.
(20-34years old? attractive UK women, famous in Japan)

I like Ms.Cara Delevigne and Ms.Sienna Guillory. Very good. Attractive!

referrence: Attractive UK women

logo.jpg Unadon
I like 26 women.

dastatis hojo.png

logo.jpg Unadon
I like twenty-six women very much. I also like four women, too.

dastatis hojo.png
You really like girls.
Certainly, I think it is a very good thing,
because you are good at finding out the each girl's charm!

logo.jpg Unadon
Thank you, dastatis.
You are a nice man.

dastatis hojo.png
Then, wee need as further data,
UK population,
number of Londoners,
the number of women between the ages of 20 and 34,
the probability that the UK girls likes us,
and the probability that the partner is unmarried.

logo.jpg Unadon
Here is the data of population in UK(from 1960 to 2014).
Let's estimate, at first, the UK population of 2017 using Bayesian state space model.

dastatis hojo.png
In the Population data 2014,
I found the number of Londoners(8,538,689),
and the number of females in London
(female, 17-31 years old = 1,020,490).
So, Let's estimate the ratio of 20-34-year-old female in 2017 in London
from the data of 2014 in consideration of error.
I will assume binomial-beta distributions as priors.

logo.jpg Unadon
2014 data shows unmarried Londoner female as 41%(0.41).
Let's use this value.

dastatis hojo.png
Finally, I set the probability that an Londoner female likes us, 0.05.

logo.jpg Unadon
OK, that is included our hope.

Bayesian Modelings for our "Possible girlfriends"

logo.jpg Unadon
This is my state space model to estimate population UK in 2017(Figure1)。
Figure1: Bayesian Delta State Space model

dastatis hojo.png
Leave the Drake equaiton modeling to me!!!(Figure2)
Figure2: Bayesian model of drake equation for "Possible girlfriend"

logo.jpg Unadon
You always write the code fast.

dastatis hojo.png
Yes! Let's MCMC(*´Д`)!
I want a posterior girlfriend as soon as possible!!

logo.jpg Unadon
My stan_code is below.
data {
    int t;
    int N[t];


transformed parameters{
    real delta[t-1];
    delta[1] = (mu_s[2]-mu_s[1]);
    delta[2] = (mu_s[3]-mu_s[2]);
    for(i in 3:(t-1)){
        delta[i] = (delta[i-2]+delta[i-1])/2;

model {
    mu_s[1] ~ normal(52400000,sigma_s);
    mu_s[2] ~ normal(52400000,sigma_s);
    mu_s[3] ~ normal(mu_s[2]+delta[1],sigma_s);
    sigma_s ~ cauchy(0,25);
    sigma ~ cauchy(0,25);
    for (j in 4 : t){
        mu_s[j] ~ normal(mu_s[j-1]+delta[j-1],sigma_s);
    int index;
        for (k in 1:t){
            if (N[k]!=9999){
               N[k] ~ normal(mu_s[k],sigma);
              N_pred[index] ~ normal(mu_s[k],sigma);
dastatis hojo.png
This is my drake equation using R and rstan!
data {
    int<lower=0> NL; //Londener
    int<lower=0> mu; //UK population
    int<lower=0> NLF; //Londener Female
    int<lower=0> NLFA; //Londener Female Age-appropriate
    int<lower=0> kgA; //UK girls Attractive
    int<lower=0> Ng; //UK girls
    real<lower=0, upper=1> xi; //Unmarried rate of kgA
    real<lower=0, upper=1> omega; //desire rate
    real<lower=0, upper=1> pi; //women rate of mu
    real<lower=0, upper=1> theta; //rate of NLF
    real<lower=0, upper=1> phi; //rate of NLFA
    real<lower=0, upper=1> psi; //rate of kgA
transformed parameters{
    real<lower=0> G; //Possible Girl Friend
    G = mu * pi * theta * phi * psi * xi * omega;
    pi ~ beta(1,1);
    theta ~ beta(1,1);
    phi ~ beta(1,1);
    psi ~ beta(1,1);
    NL~ binomial(mu, pi);
    NLF~ binomial(NL, theta);
    NLFA~ binomial(NLF, phi);
    kgA~ binomial(Ng, psi);

Result: the number of our "possible girlfriends"

logo.jpg Unadon
MCMC~ ♪ HMC~ ♪(*´Д`)
MCMCstate.png ...Finish!
Well mixed and convergence!!!(Figure3)!
Figure3: the prediction and forecasting (population UK)

logo.jpg Unadon
... And this is a posterior predictive distribution
of population UK in 2017(Figure4)
Figure4 : posterior predictive distributio

logo.jpg Unadon
I will pass the μ= 65,321,365(pred 2017 Population)!

dastatis hojo.png
μ= 65,321,365,  I caught it!!
just I it passed on stan, and...
pressed Enter!!
(*´Д`) HMC~ ♪

logo.jpg Unadon
I am looking forward to the results!
Isn't it over yet?

dastatis hojo.png
Mr. Unadon, check it out(Figure5)!!!
This is our "Possible Girlfriends"!! 
Figure5: The number of our "Possible Firlfriends" in London 2017(Posteiror)

logo.jpg Unadon
...?...? How many our girlfriend are there in 2017 in London??

dastatis hojo.png
Posterior mean indicates 17,653!

logo.jpg Unadon

So, when I met a 20-34 year old woman in London,
what is the probability that she is a possible girlfriend?

dastatis hojo.png
Now that I have a hope for London!


logo.jpg Unadon
Let's go to London to meet 17,653 possible our girlfriend!!
When we go to UK for MathPsych 2017, find a girl in London, at firs...

dastatis hojo.png
Wait. Wait please, Mr.Unadon.
Let's join the conference seriously.
There will be beautiful and smart girls
in the conference of Mathematical Psychology 2017.
You surely will have a wonderful encounter there.

logo.jpg Unadon
Yes, I got it, dastatis.
Let's do our best poster presentation!

dastatis hojo.png
Yes! I'm looking forward to the summer in UK.

Mathematical Psychology 2017!!


Thank you for your visiting this page.

Written on March 31, 2017