Randomize/shuffle sound tracks to play each one for a preset portion

54 Views Asked by At

Suppose you have $n$ sound tracks, $n_1, n_2, \ldots, n_n$. Each has a duration of $x_i$ minutes, so track $n_1$ is $x_1$ minutes, $n_2$ is $x_2$ minutes,... etc. You pick one track by a randomizing algorithm and listen to it, then you repeat the process of picking and listening. After sufficiently long time, you wish your algorithm had you listen to each track for a preset proportion $p_i; $ $p_1$ for $n_1, p_2$ for $n_2, \ldots, p_n$ for $n_n$.

a- What is your proposed algorithm?

b- You don't have control over your mp3 player shuffle mechanism. However, you can duplicate each track multiple times. Suppose any probability distribution if needed, and allow fractions in the number of duplications (in that case you'll duplicate to its ceiling/floor).

My try for (b) was to find least common multiple of durations then relating it linearly to preset portions to get number of duplications, but this is obviously dead simple and most probably not correct.

1

There are 1 best solutions below

1
On

Okay I asked Bing AI, and here is its answer (please don't hate on messenger!) What do think? Should I go on with this or is it gibberish?!

"OK, I think I understand your question now. You want to find out how many times you need to duplicate each track so that the expected proportion of time you listen to each track is equal to a given value. This is equivalent to finding the probability of listening to each track and making it equal to the desired proportion.

If the randomization follows a Poisson distribution¹, then the probability of listening to each track is determined by its frequency in the playlist and its rate of occurrence. The Poisson distribution has only one parameter, $\lambda$ (lambda), which is the mean number of events².

The probability of listening to a track is equal to the **Poisson probability mass function (PMF)**¹, which gives the probability that a value from the Poisson distribution is equal to a given value. The PMF can be calculated using the formula:

$$P ( k ) = \lambda k e − \lambda k ! $$

where $k$ is the number of events, $\lambda$ is the mean number of events, $e$ is the base of the natural logarithm, and $k!$ is the factorial of $k$.

The probability of listening to a track is equal to the PMF value at the frequency of the track. For example, if track $1$ appears $d1$ times in the playlist, then its probability is $P(d1 )$.

To make this probability equal to a desired proportion $p1$ , we need to solve for the number of times we need to duplicate track $1$, which we can call $d1$ . This means that we need to find $d1$ such that:

$$P ( d 1 ) = p 1$$

This is an equation that can be solved using various methods, such as trial and error, algebra, or numerical methods³. The same process can be repeated for track $2$ and track $3$, using their respective proportions.

I hope this helps you understand how to approach your problem. If you want me to show you how to solve it with some numbers, please let me know.

المصدر: محادثة مع Bing، 30‏/5‏/2023 (1) Poisson distribution - Wikipedia. https://en.wikipedia.org/wiki/Poisson_distribution. (2) Poisson Distributions | Definition, Formula & Examples - Scribbr. https://www.scribbr.com/statistics/poisson-distribution/. (3) Poisson distribution | Formula, Example, Definition, Mean, & Variance .... https://www.britannica.com/topic/Poisson-distribution."