Simulate MLE for Poisson distribution
Clash Royale CLAN TAG#URR8PPP
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;
up vote
1
down vote
favorite
According to the theory given $X_i$ ~ $Pois(lambda)$ iid, the maximum likelihood must be equal to $sum_i=1^n X_i/n$ in this case $5.01$
from scipy.stats import poisson
from datascience import *
import numpy as np
%matplotlib inline
import matplotlib.pyplot as plots
plots.style.use('fivethirtyeight')
# Poisson r.v.
Pois = Table().with_column('PDF',np.random.poisson(lam=5,size=10000))
Pois.hist()
#log-likelihood
def l(lam):
logs = make_array()
for k in Pois.column(0):
logs = np.log(poisson.pmf(k=k,mu = lam))
return np.sum(logs)
# lambdas
lams = np.arange(3,7,0.1)
# likelihood
ls = make_array()
for lam in lams:
print(lam)
ls = np.append(ls, np.exp(l(lam)))
plots.plot(lams,ls)
However, according to the plot the MLE is approximately when lambda = 3
python maximum-likelihood poisson-distribution simulation
add a comment |Â
up vote
1
down vote
favorite
According to the theory given $X_i$ ~ $Pois(lambda)$ iid, the maximum likelihood must be equal to $sum_i=1^n X_i/n$ in this case $5.01$
from scipy.stats import poisson
from datascience import *
import numpy as np
%matplotlib inline
import matplotlib.pyplot as plots
plots.style.use('fivethirtyeight')
# Poisson r.v.
Pois = Table().with_column('PDF',np.random.poisson(lam=5,size=10000))
Pois.hist()
#log-likelihood
def l(lam):
logs = make_array()
for k in Pois.column(0):
logs = np.log(poisson.pmf(k=k,mu = lam))
return np.sum(logs)
# lambdas
lams = np.arange(3,7,0.1)
# likelihood
ls = make_array()
for lam in lams:
print(lam)
ls = np.append(ls, np.exp(l(lam)))
plots.plot(lams,ls)
However, according to the plot the MLE is approximately when lambda = 3
python maximum-likelihood poisson-distribution simulation
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
According to the theory given $X_i$ ~ $Pois(lambda)$ iid, the maximum likelihood must be equal to $sum_i=1^n X_i/n$ in this case $5.01$
from scipy.stats import poisson
from datascience import *
import numpy as np
%matplotlib inline
import matplotlib.pyplot as plots
plots.style.use('fivethirtyeight')
# Poisson r.v.
Pois = Table().with_column('PDF',np.random.poisson(lam=5,size=10000))
Pois.hist()
#log-likelihood
def l(lam):
logs = make_array()
for k in Pois.column(0):
logs = np.log(poisson.pmf(k=k,mu = lam))
return np.sum(logs)
# lambdas
lams = np.arange(3,7,0.1)
# likelihood
ls = make_array()
for lam in lams:
print(lam)
ls = np.append(ls, np.exp(l(lam)))
plots.plot(lams,ls)
However, according to the plot the MLE is approximately when lambda = 3
python maximum-likelihood poisson-distribution simulation
According to the theory given $X_i$ ~ $Pois(lambda)$ iid, the maximum likelihood must be equal to $sum_i=1^n X_i/n$ in this case $5.01$
from scipy.stats import poisson
from datascience import *
import numpy as np
%matplotlib inline
import matplotlib.pyplot as plots
plots.style.use('fivethirtyeight')
# Poisson r.v.
Pois = Table().with_column('PDF',np.random.poisson(lam=5,size=10000))
Pois.hist()
#log-likelihood
def l(lam):
logs = make_array()
for k in Pois.column(0):
logs = np.log(poisson.pmf(k=k,mu = lam))
return np.sum(logs)
# lambdas
lams = np.arange(3,7,0.1)
# likelihood
ls = make_array()
for lam in lams:
print(lam)
ls = np.append(ls, np.exp(l(lam)))
plots.plot(lams,ls)
However, according to the plot the MLE is approximately when lambda = 3
python maximum-likelihood poisson-distribution simulation
python maximum-likelihood poisson-distribution simulation
asked 1 hour ago
Sargis Iskandaryan
1104
1104
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
2
down vote
accepted
I got this plot, which looks pretty good, $lambda _mle approx5 approx lambda$
Did you use the same code?
– Sargis Iskandaryan
21 mins ago
yap! on python 3.7... though I needed to install the datascience package, never heard of it before. Oh and I remove the Pois.hist(), since it resulted in an error
– Cherny
19 mins ago
Ok, thank you. It is strange because I have been struggling with this two days. The plot I get looks like an exponential decay.
– Sargis Iskandaryan
9 mins ago
BTW datascience package is from berkeley course data8. Here is a link if you are interested data8.org/fa16
– Sargis Iskandaryan
5 mins ago
Not sure about the exponential decay, but maybe you looked at the distribution of the inverse? I don't want to confuse you too much but you can look at the time between events and you'll get exponential distribution, and Thanks! I'll check it out
– Cherny
2 mins ago
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
I got this plot, which looks pretty good, $lambda _mle approx5 approx lambda$
Did you use the same code?
– Sargis Iskandaryan
21 mins ago
yap! on python 3.7... though I needed to install the datascience package, never heard of it before. Oh and I remove the Pois.hist(), since it resulted in an error
– Cherny
19 mins ago
Ok, thank you. It is strange because I have been struggling with this two days. The plot I get looks like an exponential decay.
– Sargis Iskandaryan
9 mins ago
BTW datascience package is from berkeley course data8. Here is a link if you are interested data8.org/fa16
– Sargis Iskandaryan
5 mins ago
Not sure about the exponential decay, but maybe you looked at the distribution of the inverse? I don't want to confuse you too much but you can look at the time between events and you'll get exponential distribution, and Thanks! I'll check it out
– Cherny
2 mins ago
add a comment |Â
up vote
2
down vote
accepted
I got this plot, which looks pretty good, $lambda _mle approx5 approx lambda$
Did you use the same code?
– Sargis Iskandaryan
21 mins ago
yap! on python 3.7... though I needed to install the datascience package, never heard of it before. Oh and I remove the Pois.hist(), since it resulted in an error
– Cherny
19 mins ago
Ok, thank you. It is strange because I have been struggling with this two days. The plot I get looks like an exponential decay.
– Sargis Iskandaryan
9 mins ago
BTW datascience package is from berkeley course data8. Here is a link if you are interested data8.org/fa16
– Sargis Iskandaryan
5 mins ago
Not sure about the exponential decay, but maybe you looked at the distribution of the inverse? I don't want to confuse you too much but you can look at the time between events and you'll get exponential distribution, and Thanks! I'll check it out
– Cherny
2 mins ago
add a comment |Â
up vote
2
down vote
accepted
up vote
2
down vote
accepted
I got this plot, which looks pretty good, $lambda _mle approx5 approx lambda$
I got this plot, which looks pretty good, $lambda _mle approx5 approx lambda$
answered 25 mins ago
Cherny
38416
38416
Did you use the same code?
– Sargis Iskandaryan
21 mins ago
yap! on python 3.7... though I needed to install the datascience package, never heard of it before. Oh and I remove the Pois.hist(), since it resulted in an error
– Cherny
19 mins ago
Ok, thank you. It is strange because I have been struggling with this two days. The plot I get looks like an exponential decay.
– Sargis Iskandaryan
9 mins ago
BTW datascience package is from berkeley course data8. Here is a link if you are interested data8.org/fa16
– Sargis Iskandaryan
5 mins ago
Not sure about the exponential decay, but maybe you looked at the distribution of the inverse? I don't want to confuse you too much but you can look at the time between events and you'll get exponential distribution, and Thanks! I'll check it out
– Cherny
2 mins ago
add a comment |Â
Did you use the same code?
– Sargis Iskandaryan
21 mins ago
yap! on python 3.7... though I needed to install the datascience package, never heard of it before. Oh and I remove the Pois.hist(), since it resulted in an error
– Cherny
19 mins ago
Ok, thank you. It is strange because I have been struggling with this two days. The plot I get looks like an exponential decay.
– Sargis Iskandaryan
9 mins ago
BTW datascience package is from berkeley course data8. Here is a link if you are interested data8.org/fa16
– Sargis Iskandaryan
5 mins ago
Not sure about the exponential decay, but maybe you looked at the distribution of the inverse? I don't want to confuse you too much but you can look at the time between events and you'll get exponential distribution, and Thanks! I'll check it out
– Cherny
2 mins ago
Did you use the same code?
– Sargis Iskandaryan
21 mins ago
Did you use the same code?
– Sargis Iskandaryan
21 mins ago
yap! on python 3.7... though I needed to install the datascience package, never heard of it before. Oh and I remove the Pois.hist(), since it resulted in an error
– Cherny
19 mins ago
yap! on python 3.7... though I needed to install the datascience package, never heard of it before. Oh and I remove the Pois.hist(), since it resulted in an error
– Cherny
19 mins ago
Ok, thank you. It is strange because I have been struggling with this two days. The plot I get looks like an exponential decay.
– Sargis Iskandaryan
9 mins ago
Ok, thank you. It is strange because I have been struggling with this two days. The plot I get looks like an exponential decay.
– Sargis Iskandaryan
9 mins ago
BTW datascience package is from berkeley course data8. Here is a link if you are interested data8.org/fa16
– Sargis Iskandaryan
5 mins ago
BTW datascience package is from berkeley course data8. Here is a link if you are interested data8.org/fa16
– Sargis Iskandaryan
5 mins ago
Not sure about the exponential decay, but maybe you looked at the distribution of the inverse? I don't want to confuse you too much but you can look at the time between events and you'll get exponential distribution, and Thanks! I'll check it out
– Cherny
2 mins ago
Not sure about the exponential decay, but maybe you looked at the distribution of the inverse? I don't want to confuse you too much but you can look at the time between events and you'll get exponential distribution, and Thanks! I'll check it out
– Cherny
2 mins ago
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstats.stackexchange.com%2fquestions%2f370705%2fsimulate-mle-for-poisson-distribution%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password