David,
The Poisson distribution tells you things like the probability of different
numbers of ambulances being dispatched.
For simulation purposes, it is usually far preferable to use the
exponential distribution to compute the time of the next ambulance. In R,
computing 100 dispatch times would look like this:
t = cumsum(rexp(100, rate=9))
You can copy code from logsynth to do this as well:
https://github.com/tdunning/logsynth/blob/master/src/main/java/com/mapr/synth/samplers/ArrivalSampler.java
The next thing that you will need to worry about is how to handle variable
rates. One good way to do this is to generate departures in a fictitious
time and then do time warping to get the variable rates. The idea is that
fictitious time would pass at a faster rate during the day than at night.
On Mon, Aug 31, 2015 at 9:21 AM, Kulpanowski, David <DKulpanowski@leegov.com
> wrote:
> Hi:
> I am working on a relatively simple project. I am attempting to generate a
> Poisson distribution for the number of ambulances that are dispatched. I
> have looked at my database and determined the average number of ambulances
> dispatched is 9
> How do I get a Poisson distribution to be generated using the Commons Math?
>
> The output I am expecting to generate looks like this....
>
> Likelihood of 1 ambulance dispatched is 0.005
> Likelihood of 2 ambulances dispatched is 0.015
> Likelihood of 3 ambulances dispatched is 0.034
> Likelihood of 4 ambulances dispatched is 0.61
> Likelihood of 5 ambulances dispatched is 0.091
> Likelihood of 6 ambulances dispatched is 0.117
> Etc.
>
> This is probably a very simple programming question for many of you. But
> for me as a novice it is not easy.
>
> So far, here is what I have using Commons Math;
>
> import org.apache.commons.math3.distribution.PoissonDistribution;
>
> public class poissonDistribution
> {
> public static void main(String[] args)
> {
> PoissonDistribution ambulanceDistribution = new
> PoissonDistribution(9);
> System.out.println(ambulanceDistribution);
> }
> }
>
> The console output is;
> "org.apache.commons.math3.distribution.PoissonDistribution@27716f4"
>
> I did try and take matters into my own hands and write the equation out
> (shown below). But I have a very strong preference to use a method provided
> by Commons Math. I am much more confident in Commons Math than my own
> abilities.
>
> The following is my code. It works in a fashion, but I am not confident in
> it. Shown below is what I am currently using  but prefer to avoid using
> this;
> import java.lang.Math;
> public class PoissonExperiment1
> {
> public static void main(String[] args)
> {
> // c is the average number of calls per hour. This is a
> variable that is
> // derived from your database.
> double c = 9.0;
> // k is the number of expected calls we want to determine
> the probability
> int k = 1;
> while (k <= 20)
> {
> int factorialResult = 1;
> for (int i = 1; i <= k; i++)
> {
> factorialResult = factorialResult * i;
> }
> double term1 = (Math.pow(Math.E, c));
> double term2 = Math.pow(c, k);
> double numerator = term1 * term2;
> double answer = numerator / factorialResult;
> System.out.format("%10.3f:%n ", answer);
> k++;
> }
> }
> }
>
>
> Thank you for your consideration and time,
> David
>
> David Kulpanowski
> Database Analyst
> Lee County Public Safety
> PO Box 398
> Fort Myers, FL 33902
> DKulpanowski@Leegov.com
> 2395333962
>
>
>
> ________________________________
> Please note: Florida has a very broad public records law. Most written
> communications to or from County Employees and officials regarding County
> business are public records available to the public and media upon request.
> Your email communication may be subject to public disclosure.
>
> Under Florida law, email addresses are public records. If you do not want
> your email address released in response to a public records request, do not
> send electronic mail to this entity. Instead, contact this office by phone
> or in writing.
>
