Arrivals and departures in discrete time

  • Thread starter Thread starter Lobotomy
  • Start date Start date
  • Tags Tags
    Discrete Time
Click For Summary

Discussion Overview

The discussion revolves around calculating the number of items in a system at discrete time intervals based on given arrival and departure data. Participants explore how to derive two new vectors representing the state of the system over time using mathematical operations on the provided data.

Discussion Character

  • Technical explanation
  • Mathematical reasoning
  • Debate/contested

Main Points Raised

  • One participant presents a scenario with arrival and departure times, seeking a method to calculate the number of items in the system at each time point.
  • Another participant suggests taking the union of arrival and departure times, constructing a running sum based on positive and negative values, and then reducing the results to obtain the desired vectors.
  • A similar response reiterates the proposed method but emphasizes the need for a purely mathematical approach without manual calculations, given the large size of the data.
  • Participants express the necessity for a simple algorithm to automate the calculations rather than performing them manually.

Areas of Agreement / Disagreement

There is no consensus on a specific method to calculate the desired vectors, and participants present competing approaches and interpretations of the problem. The discussion remains unresolved regarding the best algorithmic solution.

Contextual Notes

Participants note the challenge of handling large vectors (length 10,000) and the need for efficient computational methods, which may limit the applicability of proposed solutions.

Lobotomy
Messages
55
Reaction score
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
 
Physics news on Phys.org
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.
 
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
 
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.
 
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
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K