poisson

Determine waiting times between plane arrivals python

谁说我不能喝 提交于 2021-02-11 14:46:21
问题 I'm writing a program, that takes 200 planes distributed with the poisson distribution over 12 hours and these planes need to land at an airfield that only has 1 runway. I use the reverse CDF method from the exponential distribution to determine the inter-arrival times. However, I can't seem to calculate the waiting time in the air. E.g. a plane arrives at 100 seconds, takes 75 seconds to land and is done at 175 seconds. Plane 2 arrives at 150 seconds and must wait 175-150 = 25 seconds. How

R: Overlay Poisson distribution over histogram of data

与世无争的帅哥 提交于 2021-02-11 13:44:15
问题 I have some discrete data, which I have plotted in a histogram. I'd like to overlay a Poisson distribution to show the data is roughly Poisson distributed. Imagine the two plots from the code below merging into one plot, that is what I'd like to achieve. # Read data data <- read.csv("data.csv") # Plot data hist(data, prob=TRUE) # Plot Poisson c <- c(0:7) plot(c, dpois(c, mean(data)), type="l") I have tried the curve function: curve(c, dpois(x=c, lambda=mean(data)), add=T) But all I get is

Python: endog has evaluated to an array with multiple columns

时光毁灭记忆、已成空白 提交于 2021-02-10 15:52:19
问题 I'm trying to run a Poisson model, like this: poisson_model_xg = smf.glm(formula="xG ~ home + team + opponent", data=xg_model_data, family=sm.families.Poisson()).fit() I'm getting the following error: ValueError: endog has evaluated to an array with multiple columns that has shape (760, 9). This occurs when the variable converted to endog is non-numeric (e.g., bool or str). But I can't figure out what does it mean, since all my dataframe is numeric: xg_model_data.apply(lambda s: pd.to_numeric

Python: endog has evaluated to an array with multiple columns

柔情痞子 提交于 2021-02-10 15:48:22
问题 I'm trying to run a Poisson model, like this: poisson_model_xg = smf.glm(formula="xG ~ home + team + opponent", data=xg_model_data, family=sm.families.Poisson()).fit() I'm getting the following error: ValueError: endog has evaluated to an array with multiple columns that has shape (760, 9). This occurs when the variable converted to endog is non-numeric (e.g., bool or str). But I can't figure out what does it mean, since all my dataframe is numeric: xg_model_data.apply(lambda s: pd.to_numeric

Robust Standard Errors: Poisson Panel Regression (pglm, lmtest)

我的未来我决定 提交于 2021-01-29 10:33:28
问题 As a non-statistician I reached my limit here: I try to fit a Poisson model for panel data (using pglm ) and I want to calculate robust standard errors (using lmtest ). My code currently looks like this: #poisson model (panel with year fixed effects): poisson_model <- pglm(y ~ a + b + c + factor(year), data = regression_data, model = "pooling", family = poisson, index = c("ID", "year")) #robust standard errors: robust_SE_model <- coeftest(poisson_model, vcov. = vcovHC(poisson_model, type =

Scipy poisson distribution with an upper limit

谁说胖子不能爱 提交于 2021-01-28 01:54:36
问题 I am generating a random number using scipy stats. I used the Poisson distribution. Below is an example: import scipy.stats as sct A =2.5 Pos = sct.poisson.rvs(A,size = 20) When I print Pos, I got the following numbers: array([1, 3, 2, 3, 1, 2, 1, 2, 2, 3, 6, 0, 0, 4, 0, 1, 1, 3, 1, 5]) You can see from the array that some of the number,such as 6, is generated. What I want to do it to limit the biggest number(let's say 5), i.e. any random number generated using sct.poisson.rvs should be equal

Performance for drawing numbers from Poisson distribution with low mean

北城余情 提交于 2020-05-28 06:03:48
问题 In order to draw random number from a Poisson distribution in C++, it is generally advised to use RNG_type rng; std::poisson_distribution<size_t> d(1e-6); auto r = d(rng); At each call of the std::poisson_distribution object, an entire sequence of random bits is consumed (e.g. 32 bits with std::mt19937, 64 bits for std::mt19937_64). It strikes me that with such low mean ( mean = 1e-6 ), the vast majority of times, only a few bits are enough to determine that the value to return is 0. The

How to sample inhomogeneous Poisson processes in Python faster than this?

蓝咒 提交于 2020-05-11 07:36:06
问题 I'm sampling a Poisson process at a millisecond time scale where the rate is not fixed. I discretise the sampling process by checking in each interval of size delta whether there is an event there or not based on the average rate in that interval. Since I'm using Python it's running a bit slower than I would hope it to be. The code I'm currently using is the following: import numpy def generate_times(rate_function,max_t,delta): times = [] for t in numpy.arange(delta,max_t,delta): avg_rate =

Truncating Poisson distribution on desired support in Matlab

回眸只為那壹抹淺笑 提交于 2020-03-23 07:43:10
问题 I want to construct a 3-dimensional Poisson distribution in Matlab with lambda parameters [0.4, 0.2, 0.6] and I want to truncate it to have support in [0;1;2;3;4;5] . The 3 components are independent. This is what I do clear n=3; %number components of the distribution supp_marginal=0:1:5; suppsize_marginal=size(supp_marginal,2); supp_temp=repmat(supp_marginal.',1,n); supp_temp_cell=num2cell(supp_temp,1); output_temp_cell=cell(1,n); [output_temp_cell{:}] = ndgrid(supp_temp_cell{:}); supp=zeros