poisson

ggplot Poisson density curve: why zigzag lines?

巧了我就是萌 提交于 2019-12-07 11:19:48
问题 I would like to plot the density function of a Poisson distribution. I am not sure why I get a jaggy line (in blue). On the sample plot, the normal density curve (in red) looks smooth. It is because the reason the Poisson density function doesn't accept decimal values? How to eliminate the zigzag in the Poisson density plot? Thanks very much for any help. library(ggplot2) ggplot(data.frame(X = seq(5, 30)), aes(x = X)) + stat_function(fun=dpois, geom="line", size=2, color="blue3", args = list

hand-rolled R code for Poisson MLE

那年仲夏 提交于 2019-12-07 07:25:36
I'm attempting to write my own function to understand how the Poisson distribution behaves within a Maximum Likelihood Estimation framework (as it applies to GLM). I'm familiar with R's handy glm function, but wanted to try and hand-roll some code to understand what's going on: n <- 10000 # sample size b0 <- 1.0 # intercept b1 <- 0.2 # coefficient x <- runif(n=n, min=0, max=1.5) # generate covariate values lp <- b0+b1*x # linear predictor lambda <- exp(lp) # compute lamda y <- rpois(n=n, lambda=lambda) # generate y-values dta <- data.frame(y=y, x=x) # generate dataset negloglike <- function

Is random.expovariate equivalent to a Poisson Process

穿精又带淫゛_ 提交于 2019-12-07 06:49:25
问题 I read somewhere that the python library function random.expovariate produces intervals equivalent to Poisson Process events. Is that really the case or should I impose some other function on the results? 回答1: On a strict reading of your question, yes, that is what random.expovariate does. expovariate gives you random floating point numbers, exponentialy distributed. In a Poission process the size of the interval between consecutive events is exponential. However, there are two other ways I

Poisson point process in matlab

柔情痞子 提交于 2019-12-06 14:58:50
问题 I am new with poisson point process. I did one simluation (matlab) as below. My intensity lambda = 50 ; clear all; lambda=50; npoints = poissrnd(lambda); pproc = rand(npoints, 2); plot(pproc(:, 1), pproc(:, 2), '.'); Then I have plot, However, the link http://connor-johnson.com/2014/02/25/spatial-point-processes/ showed me that when intensity lamuda = 0.2, smaller than 1 , he got The link also showed the code in Python.Please check it. Here is my question, why intensity is smaller than 1 , he

Error with custom density function definition for mle2 formula call

℡╲_俬逩灬. 提交于 2019-12-06 11:31:39
I want to define my own density function to be used in the formula call to mle2 from R 's bbmle package. The parameters of the model are estimated but I cannot apply functions like residuals or predict on the returned mle2 object. This is an example in which I define a function for a simple Poisson model. library(bbmle) set.seed(1) hpoisson <- rpois(1000, 10) myf <- function(x, lambda, log = FALSE) { pmf <- (lambda^x)*exp(-lambda)/factorial(x) if (log) log(pmf) else pmf } myfit <- mle2(hpoisson ~ myf(lambda), start = list(lambda=9), data=data.frame(hpoisson)) residuals(myfit) In myfit , the

Adding poisson noise to an image

无人久伴 提交于 2019-12-06 07:33:14
问题 I have some images that I need to add incremental amounts of Poisson noise to in order to more thoroughly analyze them. I know you can do this in MATLAB, but how do you go about doing it in Python? Searches have yielded nothing so far. 回答1: If numpy/scipy are available to you, then the following should help. I recommend that you cast the arrays to float for intermediate computations then cast back to uint8 for output/display purposes. As poisson noise is all >=0, you will need to decide how

generating poisson variables in c++

守給你的承諾、 提交于 2019-12-06 03:27:27
问题 I implemented this function to generate a poisson random variable typedef long unsigned int luint; luint poisson(luint lambda) { double L = exp(-double(lambda)); luint k = 0; double p = 1; do { k++; p *= mrand.rand(); } while( p > L); return (k-1); } where mrand is the MersenneTwister random number generator. I find that, as I increase lambda, the expected distribution is going to be wrong, with a mean that saturates at around 750. Is it due to numerical approximations or did I make any

Can't understand Poisson part of Hash tables from Sun documentation

我的未来我决定 提交于 2019-12-05 14:43:58
问题 I am trying to understand how HashMap is implemented in Java. I decided that I will try to understand every line (of code and comments) from that class and obviously I faced resistance very soon. The following snippet is from HashMap class and talks about Poisson Distribution: Ideally, under random hashCodes, the frequency of nodes in bins follows a Poisson distribution (http://en.wikipedia.org/wiki/Poisson_distribution) with a parameter of about 0.5 on average for the default resizing

ggplot Poisson density curve: why zigzag lines?

为君一笑 提交于 2019-12-05 13:45:57
I would like to plot the density function of a Poisson distribution. I am not sure why I get a jaggy line (in blue). On the sample plot, the normal density curve (in red) looks smooth. It is because the reason the Poisson density function doesn't accept decimal values? How to eliminate the zigzag in the Poisson density plot? Thanks very much for any help. library(ggplot2) ggplot(data.frame(X = seq(5, 30)), aes(x = X)) + stat_function(fun=dpois, geom="line", size=2, color="blue3", args = list(lambda = 15)) + stat_function(fun=dnorm, geom="line", size=2, color="red4", args = list(mean=20, sd=2))

Is random.expovariate equivalent to a Poisson Process

老子叫甜甜 提交于 2019-12-05 09:29:18
I read somewhere that the python library function random.expovariate produces intervals equivalent to Poisson Process events. Is that really the case or should I impose some other function on the results? On a strict reading of your question, yes, that is what random.expovariate does. expovariate gives you random floating point numbers, exponentialy distributed. In a Poission process the size of the interval between consecutive events is exponential. However, there are two other ways I could imagine modelling poisson processes Just generate random numbers, uniformly distributed and sort them.