This task is related to optimization problems, where we set the objective function equal to a given fixed number, subject to a number of constraints. Consider a gambling situation. We have a particular box, with one of $n$ items inside. The probability of getting $i$th item from the box is $p_i$. Pulling from a particular item from the box is an elementary outcome: these outcomes are independent of each other, and the sum of the probabilities of the onset of all elementary outcomes is equal to one. A player wants to open the box, and he pays a price of $C$ for this. Each of $n$ items that may be pulled from the box has its value $c_i,i=(1,n)$ ̅. These values may be smaller or significantly greater than the box price. Let $x$ is a random variable, which reflects the value of an item pulled from the box. This is a discrete random variable, therefore, its expectation is: $$E(x)=\sum_{i=1}^nc_i p_i $$ A game owner has a desired level of profitability, which can be calculated as follows: $$R(x)=\frac{C-E(x)}{C}$$ In addition, the owner wants this profitability to be controlled by changing the probabilities of elementary outcomes in the way, such that $R(x)=R_0$, the desired level of profitability. Box price and values of all items, as well as their number are constants. Some probabilities, for example, $p_1,…,p_k,k<n$, can be manually assigned, therefore, the remaining variables will be only $p_(k+1),….,p_n$. Upon studying competitors’ experience, it was found out that there is a requirement to the distribution of random variable $x$. In particular, this distribution should be skewed to the right:
Let’s sort the prices on items in the ascending order of price levels: $c_1≤c_2≤⋯≤c_n$
Then, we come to the optimization problem of the following form:
Set the objective function $R(x)=1-\frac{\sum_{i=1}^nc_i p_i}{C}→R_0$ Subject to constraints: $$p_1,p_2,…p_n>0$$ $$\sum_{i=1}^np_i =1$$ $$p_1<p_2<⋯<p_m$$ $$p_n<p_{n-1}<⋯<p_m$$ Where $m$ is an index of a particular item, pulled from the box, with a cost $c_m$, which depends from the value of the box approximately as follows (these bounds were received experimentally): $$0.4C≤c_m≤1.15C$$ The last constraint is an attempt to assign higher probabilities to items with “middle” level of values, as compared to those with low and high values. This should imply the probability distribution to have the desired form.
What is required? To write down the algorithm of calculations, which can solve the optimization problem and can be implemented on PhP. This task can be solved in Excel using Excel Solver, however, since we cannot work with Excel files effectively, we need a manually written algorithm, which can be implemented in a programming code.