I am trying to understand the best practices regarding AnyLogic's source arrival rates. I know that Exponential and Poisson are two different probability distributions. When using "Arrival Rate" in AnyLogic and choosing a rate of 10/hour for example, does this generate 10 agents per hour exponentially or according to a Poisson distribution or is it the same thing?
I really need guidance on understanding the best practices in this matter. To simplify the question, if I have an arrival rate of 10/hour following a Poisson distribution, what is the right way to model that in AnyLogic?
Many thanks!
In any source in AnyLogic, if you choose a rate, it will automatically be poisson where your rate will be the lambda parameter of your poisson distribution... this means that in average you will get lambda agents per time unit generated
The exponential distribution is equivalent to the poisson distribution, except that it takes into consideration the time between each arrival instead. (this means that you need to use arrivals defined by inter-arrival time in your source, otherwise it wouldn't make much sense)
poisson(lambda) arrivals per time unit is equivalent to exponential(lambda) time units per arrival, it doesn't really matter which one you use
Related
I am currently simulating a parking place in AnyLogic and wanted to set the arrival rate with a normal distribution. But I don't exactly know how to set a normal distribution peaking for example exactly at 3pm.
Any suggestions are appreaciated. Thanks in advance.
To do this you need to change the arrival rate according to a normal distribution in time.
That means that you need some function (tableFunction might work for instance) that gets the current time as an input and the arrival rate as an output.
You will then change the arrival rate every hour, or every 10 minutes depending on your model... your arrivals will continue following a poisson arrival, but your arrival rate throughout the day will follow any distribution you want.
I'm studying Anylogic. I'm curious about something.
Some people explain that arrival rate follows Exponential Distribution.
I wanna know 'How can prove that?'
Any kind guidance from you would be very helpful and much appreciated.
Thank you so much.
The arrival rate doesn't follow an exponential distribution, it follows a poisson distribution, so there's nothing to prove on that regard.
What follows an exponential distribution is the inter-arrival time between agents.
To prove that this thing actually follows a particular distribution, you can use one of the many distribution fitting techniques out there, my favorite and the one is the Cullen and Frey Graph. You can see an answer about it here:
https://stats.stackexchange.com/questions/333495/fitting-a-probability-distribution-and-understanding-the-cullen-and-frey-graph
You can also check the wikipedia page on distribution fitting:
https://en.wikipedia.org/wiki/Probability_distribution_fitting
Have in mind that distribution fitting is kinda an art, and no technique gives you the correct distribution, but maybe a good enough approximation of a distribution. But in this case it should be quite easy.
You can't really prove that a distribution fits the data though, you can just have maybe an error estimation when you compare the distribution function with the actual data, and you can have a confidence interval for that... I'm not sure if that's what you want.
not exactly sure what you mean by "prove" that it is exponential... But anyway, it is not "some people" that explain that, it is actually mentioned in AnyLogic help under the "Source" topic as follows:
Rate - agents are generated at the specified arrival rate (which is
equivalent to exponentially distributed interarrival time with mean =
1/rate).
What you can do is collect the interval time between arrivals and plot that distribution to see that it actually looks like an exponential distribution.
To do that:
Create a typical DES process (e.g. source, queue, delay, sink)
Set the arrival type to rate and specify for example 1 per hour
Create a variable in main called "prevTime"
Create a histogram data element called "data"
In the "On exit" of the source write the following code:
data.add(time() - prevTime);
prevTime = time();
Look at the plot of the histogram and its mean.
I have come across a quite complex scenario. I have actual data of the following:
Queue length distribution
Queue waiting time distribution
Distribution of the number of agents arriving every day (but not their pattern of arrival throughout the day)
The process can be assumed as a simple "source > queue > delay > sink"
Is there a way to find an arrival rate and a delay time distribution to match the available actual data? I understand that mathematically there might be many solutions to such a problem. But is there a way at all to approach this situation in AnyLogic?
I managed to meet the average queue length and average waiting time but as a distributions, the queue length and queue waiting time are not close to the actual data set.
This is a parameter calibration problem, in which your parameters are the lambdas of your poisson arrival rate for each hour of the day or so, and the parameters of a triangular distribution for your waiting times (delay).
The arrival rates are always poisson, so no need to have a debate on that.
When you develop a model, when you don't know what your distribution is or you don't have data, you always use a triangular distribution.
With the parameter calibration you want to minimize the error between your data and your model. The function you want to minimize depends on the distribution you have on your data.
To know what is the distribution of your data, you can use a distribution fitting technique such as cullen and frey graph... but it seems that you already have the distribution
I have two time series of data, one which is water temperature and the other is air temperature (hourly measurements for one year). Both measurements are taken simultaneously and the vectors are therefore the same size. The command corrcoef illustrates that they have a correlation equal to ~0.9.
Now I'm trying a different approach to find the correlation where I was thinking of spectral coherence. As far as I understand, in order to do this I should find the autospectral density of each time series? (i.e. of water temperature and air temperature) and then find the correlation between them?
As I am new to signal processing I was hoping for some advice on the best ways of doing this!
I would recommend consulting this site. It contains an excellent reference to your question. If you need help with the cohere function, let me know.
I have a Simulink xPC target application that has blocks with discrete states at several different sample rates and some sections using continuous states. My intention on keeping the continuous states is for better numerical integration.
What creates the problem: One block is reading a device at a very fast rate (500 hz). The rest of the application can and should run at a slower rate (say, 25 or 50 Hz) because it would be overkill to run it at the highest rate, and because the processor simply cannot squeeze a full application cycle into the .002 secs of the faster rate. So I need both rates. However, the continuous states run by definition in Simulink at the faster discrete rate of the whole application! This means everywhere I have continuous states now they're forced to run at 500 Hz when 25 Hz would do!
Is there a way to force the continuous states in xPC target to a rate that is not the fastest in the application? Or alternatively, is there a way to allow certain block to run at a faster speed than the rest of the application?
You are thinking about continuous solvers in the wrong way - continuous doesn't only mean that it's run as fast as possible - it uses a fundamentally different algorithm to solve the equations than discrete. Due to this, they must be run at least as fast as the discrete solvers.
From Using Simulink:
Continuous solvers use numerical
integration to compute a model's
continuous states at the current time
step from the states at previous time
steps and the state derivatives.
Continuous solvers rely on the model's
blocks to compute the values of the
model's discrete states at each time
step.
Mathematicians have developed a wide
variety of numerical integration
techniques for solving the ordinary
differential equations (ODEs) that
represent the continuous states of
dynamic systems. Simulink provides an
extensive set of fixed-step and
variable-step continuous solvers, each
implementing a specific ODE solution
method (see Solvers).
Discrete solvers exist primarily to
solve purely discrete models. They
compute the next simulation time step
for a model and nothing else. They do
not compute continuous states and they
rely on the model's blocks to update
the model's discrete states.
So the upshot is that no it's not good enough to have the continuous run more slowly than the fastest discrete solvers - otherwise they are, by definition, not continuous. You should reconsider why you are specifying them as continuous.
What are you trying to accomplish by slowing down the continuous solvers? Is this a simulation time/performance issue?
-Adam
My take on this is that it cannot be done. One way to approach this is to replace the continuous states by discrete ones (perhaps at an intermediate rate, say 100 Hz), and cross my fingers that the loss of precision is bearable.
Maybe it's possible to isolate a block and run it separately at a faster rate somehow, but I don't know.
Truly continuous computation is impossible in a digital processor such as your computer's.
What MATLAB/Simulink means by "continuous" is "I will (dynamically) try to guess what discrete step size is small enough so that discretization error is very small in your application".
If you already know, by knowing your application, that 20ms (50Hz) would be small enough, then use discrete - 50Hz.