Arrivals and departures in discrete time

In summary, the conversation discusses a problem with calculating the number of items in a system based on discrete event arrivals and departures. The conversation also mentions using vectors and plotting graphs in Matlab to represent the data. The solution involves taking the union of two vectors, constructing a running sum, and reducing the vectors to get the desired result. It is mentioned that programming may be necessary to fully solve the problem.
  • #1
Lobotomy
58
0
Hello
I have a problem.
im looking at discrete event arrivals of items.

the x-array represents the time of arrival and if one number occurs more than once it obviousely means that more than one item arrives at the exact same time. for instance:

x=[0 0 0 0 3 3 3 3 6 6 6];

this means that 4 items arrives at time 0, 4 more items arrive at time 3 and 3 more items arrive at time 6.

the y-array equals the size of the x-array and represents the accumulated number of items.
y=[1:11];


plotting this for instance in Matlab will show you this graphically:
plot(x,y,'*')


Now the thing is that i have yet another series of measurements, of items leaving. z represents the time they are leaving similar to x. w is the accumulated number of items that has left.

z=[2 2 2 5 5 5 5 5]
w=[1:8]

plotting these together:

hold
plot(z,w,['+','g'])


now what i want to do is the calculate the the amount of items in the system at every discrete time represented in the above vectors, hence the arriving items minus the leaving items. Sounds pretty simple but i can't figure out how to do it! The hard part is because the time scale is different...

so x,y and z,w are given to me beforehand. in reality these are vectors of length 10000, and there might be several arrivals in a row followed by several items leaving in a row, so this is why i can not do it by hand here. But in my small example, the result I am looking for is:



s=[0 0 0 0 2 3 3 3 3 3 5 6 6 6];
a=[1 2 3 4 1 1 2 3 4 5 0 1 2 3];


plot(s,a,['<','r'])

notice that the a-vector must be modified since values are no longer added but subtracted.

the s-vector contains all the times of the x and z vectors, but the amount of items at each time is modified by hand.

My question is, is there a way to calculate s and a from x,y and z,w?? in the above example I've calculated it just by figuring out the result... this seems pretty simple but well i just can't figure out how to do it. please help me someone
 
Mathematics news on Phys.org
  • #2
I don't know Matlab, but here's my take.

1. Take the union of x and -z: t=[0 0 0 0 -2 -2 -2 3 3 3 3 3 -5 -5 -5 -5 -5 6 6 6]
2. Construct a running sum of the elements in t: b= [1 2 3 4 3 2 1 2 3 4 5 6 5 4 3 2 1 2 3 4], by adding 1 for every non-negative element and subtracting 1 for every negative element in t.
3. Reduce t to s by:
3.a. deleting all except the last one of a sequence of identical negative elements, e.g. -2 -2 -2 (delete the first two 2's, keep the last one)
3.b. multiplying each negative element by -1
4. Reduce b to a by deleting an element if it is less than the previous one, unless the next one is higher. E.g., in "4 3 2 1 2" mark 3 for deletion because 4 > 3 and 3 > 2, mark 2 for deletion because 3 > 2 and 2 > 1, keep 1 because 1 < 2, keep 2 because 1 < 2.
 
  • #3
EnumaElish said:
I don't know Matlab, but here's my take.

1. Take the union of x and -z: t=[0 0 0 0 -2 -2 -2 3 3 3 3 3 -5 -5 -5 -5 -5 6 6 6]
2. Construct a running sum of the elements in t: b= [1 2 3 4 3 2 1 2 3 4 5 6 5 4 3 2 1 2 3 4], by adding 1 for every non-negative element and subtracting 1 for every negative element in t.
3. Reduce t to s by:
3.a. deleting all except the last one of a sequence of identical negative elements, e.g. -2 -2 -2 (delete the first two 2's, keep the last one)
3.b. multiplying each negative element by -1
4. Reduce b to a by deleting an element if it is less than the previous one, unless the next one is higher. E.g., in "4 3 2 1 2" mark 3 for deletion because 4 > 3 and 3 > 2, mark 2 for deletion because 3 > 2 and 2 > 1, keep 1 because 1 < 2, keep 2 because 1 < 2.

hm ok... thanks ill try, but remember i can't do anywhing "by hand" all this has to be mathematical operations on a vector. since i can't go through the entire vectors manually since they are 10000 values long
 
  • #4
Lobotomy said:
hm ok... thanks ill try, but remember i can't do anywhing "by hand" all this has to be mathematical operations on a vector. since i can't go through the entire vectors manually since they are 10000 values long
Right; you should be able to come up with a simple algorithm for each individual step in my post.
 
  • #5
EnumaElish said:
Right; you should be able to come up with a simple algorithm for each individual step in my post.

yes it seems some simple programming is required rather than vector operations
 

1. What is the difference between arrivals and departures in discrete time?

In the context of discrete time, arrivals refer to the instances when an event or entity enters the system during a specific time interval. On the other hand, departures refer to the instances when an event or entity exits the system during a specific time interval. In other words, arrivals and departures are opposite processes, where arrivals increase the number of entities in the system and departures decrease the number of entities.

2. How is discrete time defined in the context of arrivals and departures?

Discrete time is a concept used in the study of arrivals and departures, where time is measured in distinct, separate intervals. This means that the system is observed at specific time points, rather than continuously. For example, in a discrete time system, arrivals and departures may be recorded every hour, rather than every minute.

3. What factors affect the arrivals and departures in a discrete time system?

There are several factors that can influence the arrivals and departures in a discrete time system. These include the rate of arrival, the rate of departure, the length of the time interval, and the number of entities in the system. Other external factors, such as environmental conditions or system constraints, can also impact the arrivals and departures.

4. How are arrivals and departures modeled in discrete time systems?

Arrivals and departures in discrete time systems are typically modeled using mathematical techniques such as queuing theory or Markov chains. These models take into account the various factors that affect arrivals and departures and help predict the behavior of the system over time. By using these models, scientists can make informed decisions to optimize the system and improve its efficiency.

5. What are some real-world applications of arrivals and departures in discrete time?

Arrivals and departures in discrete time have various real-world applications, such as in transportation systems, telecommunications, and inventory management. For example, in a transportation system, arrivals and departures can be used to predict traffic flow and optimize routes. In telecommunications, arrivals and departures can help determine call center staffing needs. In inventory management, arrivals and departures can be used to forecast demand and manage inventory levels.

Similar threads

  • General Math
Replies
2
Views
809
Replies
9
Views
1K
  • General Math
Replies
24
Views
2K
Replies
1
Views
771
  • General Math
Replies
1
Views
699
Replies
1
Views
830
  • General Math
Replies
1
Views
1K
  • Introductory Physics Homework Help
Replies
6
Views
160
Replies
5
Views
844
Replies
6
Views
1K
Back
Top