# Some fraction of random selection

Items are held in a priority queue containing $Q$ items, with $Q > 3$.  Each item has an integer priority between 1 and $P$, with $P < Q$, and the birth time it was added to the queue.

After a constant time interval an item is selected and removed from the queue and a new item is added to the queue.  The priority of the item is an integer between 1 and $P$ chosen uniformly at random, and its birth time is one greater than the birth time of the previously added item.

The item removed is chosen as follows:

With probability $R$ choose the item with the highest priority, if more than one item has the same priority the oldest item is chosen.
With probability $1-R$ choose the item uniformly at random from the queue.

The age, $a$, of an item is the difference between its birth time and the time it was removed from the queue, with $Q < a$
What is the age distribution of items removed from the queue.

what is the approximate distribution when $R > 0.9$ and $P > 5$


# Priority increases with task waiting time

Tasks are held in an accumulating priority queue containing $Q$ tasks, with $2 < Q < 10$.  At time slot $t$ the priority of each task is $K_i+a*(t-B_i)$ where $K_i$ is the initial priority given to task $i$ and $B_i$ is the time that task $i$ was added to the queue, and $a$ is a constant $0 < a < 0.5$.

The priority of the tasks initially in the queue is an integer between 1 and $P$ chosen uniformly at random, and each task has a unique birth data between 1 an $Q$.

On a recurring basis, after a constant time interval the task with the highest priority is selected and removed from the queue and a new task is added to the queue.  The initial priority of the new task is an integer between 1 and $P$ chosen uniformly at random, with $2 < P < 6$, and its birth time, $B_i$, is one greater than the birth time of the previously added task. If more than one task has the highest priority, one is chosen uniformly at random.

What is the probability distribution of the time that tasks spend in the queue?

