Thursday, July 22, 2021

How to Tune a Feature (Part 2)

 In the previous post we argued that volatility in a slot economy is determined in part by the casino operator when they set the terms of free, earned and purchased credits.  In particular, it is important to understand how much time and effort managers put into the earned credits component, and to put into clear terms why they are doing it.  It turns out they are correct to do so, and this article will begin to build a theory that can help organize how they go about this.

Previously when we looked at the earned credits component of the economy accounting identity, we assumed that the difficulty to complete was low or that players would complete the challenge.  This simplification helped us focus on the main result that although there are many combinations of reward and difficulty that result in the same return to player for the individual from that feature, there was only one combination consistent with equilibrium given casino rake.  The obvious reality though is that only a portion of the players will actually complete a feature.  Predicting and measuring this proportion is our aim.  We begin with an explicit form of earned credits.

EARNEDt(Bt,Bt-1) = k*Bt-1*I(Bt>=(1+c)*Bt-1), (1)

We are writing out the word EARNED because we are going to also use the mathematical expectation operator, E[...], and we we want to avoid confusion.  I(Bt>=(1+c)*Bt-1) is the indicator function which is equal to 1 when B>= (1+c)*Bt-1 and is 0 otherwise.  In words it guarantees that earned credits are 0 unless the player bets (1+c) times yesterdays bets, in which case they are awarded with k times yesterday's bets.

So what on average do we expect the players to earn (i.e. we take the expectation E[...])?

E[ EARNEDt(Bt,Bt-1) ] = E[ k*Bt-1*I(Bt>=(1+c)*Bt-1) ]. (2)

And by linearity of the expectation operator,

E[ EARNEDt(Bt,Bt-1) ] =  k*Bt-1*E[I(Bt>=(1+c)*Bt-1) ]. (3)

Now we apply one more trick, which is probably one of the deeper and more useful results from probability and measure theory.  The expectation of an indicator function is identical to the probability of that event.

So,

E[ EARNEDt(Bt,Bt-1) ] =  k*Bt-1*P(Bt>=(1+c)*Bt-1). (4)

Our basic algebra combined with a little probability theory gives us a precise statement.  We actually do need to understand the chance that players complete the challenge in order to manage the economy and keep it in equilibrium.  Arguing as before, we fix return to player of the feature at 2%,

k/(1+c) = 2%, (5)

and combine it with the economy accounting identity in equilibrium to get,

k*P(Bt>=(1+c)*Bt-1) = c * rake. (6)

(See "How to Tune a Feature" to make these steps clearer).

Instead of two equations in two unknowns, k and c, to determine equilibrium and return to player as we did when we assumed the player always completed, now we must estimate the probability that the player will or can bet that much. Plugging in different guesses for P shows how substantially different the answers you might get are when compared to the naïve assumption of completion.

Luckily we have some ideas about P(Bt>=(1+c)*Bt-1).  The first is that it is clearly a function of c.  Intuitively as c gets larger it is harder to complete the feature and P decreases. Graphically we might assume something like the following.

The average player is pretty much guaranteed to complete so long as expected free and paid coins can cover the ask of (1+c) times yesterday's bets, Bt-1, after which point it begins to drop off.  But how fast? and how do we account for different size bets?  Those are the interesting and difficult questions which require brave and concrete models.  Let's show how to proceed with the relevant variables and make a very strong assumption to show what is at the heart of the question.

P(Bt>=(1+c)*Bt-1) = P(St*avg(Bt)>=(1+c)*St-1*avg(Bt-1)), (7)

where St is total spins and avg(Bt) is the average bet.  If the average size of bets is constant, which is a very strong assumption, then (7) reduces simply to

P(Bt>=(1+c)*Bt-1) = P(St>=(1+c)*St-1), (8)

and this is completely calculable.  In fact it is precisely that statistic we talked about in the article about volatility.  All that needs to be done is to ask the mathematician what the range of such probabilities is for your slot machines.  When the bets must be made on a particular slot machine, you only need the full volatility information for one machine!

(8) is however a special case as often managers or players would like to change the average size of bets.  Under such conditions you must estimate how spins change with average bets.  In my experience they are directly related in log form, but there may be many more complexities and refinements to make on this and other related issues.

This ends my series of posts derived from the economy accounting identity,  Hopefully some of you have found them useful.  Please feel free to reach out directly or comment if you would like me to cover specific topics or problems.

Sunday, July 18, 2021

Volatility, Spins and RTP

As is often the case, the right answer is found by intelligent workers in a field before theoretical analysis catches up.   For example, many financial models are used by investors before they are formally analyzed by financial and economic researchers.  I'm thinking historically of CAPM or even the factors of Fama-French portfolios.

In the case of casino mathematics, we have a similar situation when measuring volatility.  Somehow, many mathematicians at different companies independently came to use median spins on a fixed bankroll to rank the volatility of machines.  This article will explore properties of the median spins statistic.

For example, a player with $20.00 making a 40 credit bet with 1 credit = 1 cent begins with 50 initial bets.  But if they play until they are out of money, the median player will get to play for many more spins, say 150 spins.  If playing with the same initial bankroll and making the same size bets on a different game the median player only gets 100 spins, we say that this game is more volatile than the other.

In the previous article we explored the graph of spins players make when they make a certain return from the casino.  We pointed out that the median player's rtp was therefore related to this overall market change in spins.  Interestingly, spins is also related to rtp at the individual level.

Consider a player with initial Wallet, W, who will make a sequence of bets {B1, B2, ...} until they can no longer afford to bet.  We get a sequence of budget constraints:

0 <= W - B1,
0 <= W - B1 - B2 + Win1,
0 <= W - B1 - B2 - B3 + Win+ Win2,
... 
0 <= W - B1 - B2 - B3 - ... - BN+ Win+ Win2 + ... + WinN-1, (1)

In words, the player is only allowed to bet B1 up to the size of wallet W.  Then adjusting wallet by the amount bet and what was won on that first spin, Win1, B2 must be no greater than that new wallet amount.  We continue in this way until the game stops on the Nth spin.

Since any win is greater than or equal to 0, we can bound (1) with

0 <= W - B1 ... - B+ Win... + WinN-1 <=  W - B1 ... - B+ Win+ ... + WinN. (2)

Next divide everything through by Total Bets = B1 + ... + BN,

0 <= W / Total Bets - 1 + RTP, (3)

or by rearranging,

Rake <= W / Total Bets. (4)

On the other hand in order to have stopped at spin N the difference of bets from wins and initial wallet must be less than the minimum bet B.

B > W - B1 ... - B+ Win+ ... + WinN. (5)

Since Average Bet >= B we get,

Average Bet >= B > W - B1 - ... - B+ Win... + WinN, (6)

and dividing by Total Bets,

Average Bet / Total Bet > W / Total Bet - 1 + RTP. (7)

Since Total Bet = N * Average Bet, we can reorganize (7) as

Rake > (W / Average Bet) / N - 1/N. (8)

Combining (4) and (8) we get

(W / Average Bet) / N - 1/N < Rake <= W / Total Bets = (W / Average Bet) / N. (9)

So, when players bet until they run out of coins, we know within 1/N coins that the casino raked (W / Average Bet) / N.  Furthermore, games mathematicians usually take B=B1=...=Bfor an "apples to apples" comparison across games, by comparing Median(RTP) or the statistic Median(N) across the games starting with an equal initial wallet in terms of multiples of bet B.

One point to make is that in practice different companies like to use the median spins stat differently.  Some prefer a 50 bet initial wallet, while others use a different number.  Some even prefer thinking about it in terms of fixed $ amounts like $20.  Deep knowledge of stopping games from stochastic processes or the seemingly unrelated signal processing field reveals that it doesn't matter too much.




The above graph compares the log(Median(N)) for different slot games in order to empirically derive the relationships of their Median(N) if you change initial bet size for a fixed $ amount.  It is clear that it isn't hard to do.  Fundamentally, volatility is a function of starting wallet, bet size and some property of the game that can be measured by statistics like Median(N) or Median(RTP) and such statistics are all very closely related to each other.

Bringing this full circle to the economy accounting identity in equilibrium,

f + e + p = rake, (10)

and recall the denominator is total bets,

( (F + E + P) / Average Bet ) / Total Spins = rake. (11)

What does that mean?  In equilibrium, where wallets are constant, the sum of free, earned and purchased coins plays the role of W in (9).  This is how the volatility of games influences total spins in the economy.  What is even more interesting about (11) though, is that players are free to choose the size of bets strategically, and of course the casino influences F, E and P.  So, volatility is determined in a strategic game between the player and casino even after the slot machine volatilities are set.

Thursday, July 15, 2021

Inflation in Token Economies

Headline inflation is fundamental to most economies and your slot economy is no exception.  Sometimes it is a slow and steady inflation as players are rewarded for moving up the experience curve.  Other times it is a surprise event wherein the casino increases the rewards for all the inflows.  This article will use the accounting identity for slot economies and the basic theories of feature tuning and sales to construct a larger analysis of a few simple strategies for inflating an economy.  The core empirical result to capture is that economic activity in total scales by exactly the rate of inflation.

To start we will consider free coins Ft, earned coins Et(Bt,Bt-1) as a function of today's and yesterday's bets, Bt and Bt-1, and purchased coins Pt = Dt*Xt where Dt is $ demand and Xt is the exchange rate.  RAKEt is the total amount of coins the casino rakes and Wt indicates wallets.  To inflate the economy we will multiply free inflows, initial wallets and the exchange rate by 10.

So,

Ft + E(Bt,Bt-1) + Pt = Wt - Wt-1 + RAKEt (1)

becomes

10*Ft-1 + Et(Bt,Bt-1) + Dt*10*Xt-1 = Wt - 10*Wt-1 + RAKEt. (2)

It's clear the casino manager's job isn't finished as they also need to think about earned credits.  Imagine first that they leave the same features running with the same rules as before the inflation,

meaning,

Et(Bt,Bt-1) = Et-1(Bt,Bt-1) = k*Bt-1*I(Bt>=(1+c)*Bt-1). (3)

(Today I've introduced the notation I(Bt>=(1+c)*Bt-1), which equals one if todays bets exceed (1+c) times yesterdays bets and is zero otherwise.  It can be added into the previous feature tuning post for greater generality.  But just ignore it, if it is confusing.)

The empirical result we see when inflating an economy is Bt  = 10*Bt-1 and W=10*Wt-1. So substituting (3) into (2) and dividing through by Bt gives

ft-1 + et-1/10 + Dt*Xt-1 = rake. (4)

we see that to reach equilibrium $ demand Dt must increase a lot compared to Dt-1 or the casino must drop rake, because earned credits have been divided by 10.  Maybe that will be too much of a change to ask of players.  So, instead we can modify (3) by demanding that players spend 10 times (1+c)*Bt-1 and will reward them correspondingly with 10 times as much coins.

So,

Et(Bt,Bt-1) = 10*Et-1(Bt,10*Bt-1) =10*k*Bt-1*I(Bt>=10*(1+c)*Bt-1). (5)

Now, substituting (5) into (2) and dividing through by B=10*Bt-1 gives us the usual equilibrium condition:

ft-1 + et-1 + Dt*Xt-1/Bt-1  = rake. (6)

Equilibrium is reached with Dt = Dt-1 and we should expect no fundamental changes to the variables Ft, Et, Bt or Wt.

The force of the casino making a profit through inflating requires balancing between these two extremes.  For example by only rewarding earned credits with a factor of 8x and requiring the players to purchase some small difference to reach equilibrium wallets.  Any irrational exuberance from feeling richer that would make the players buy more coins doesn't seem to happen as a matter of logic or in practice without some prompting.

That being said there is a hidden part to this story.  These variables like Bt are aggregates and this variable in particular, which is total bets made in coins, can be expressed as the product of total spins St and average bets,

or,

Bt = avg(Bt)St. (7)

Understanding this means that even though Bt jumps up to 10*Btavg(Bt) does not have to.  In fact I have seen St increase to make up the difference.  Managers having grown used to an economy where median wallets tracked mean wallets but with less noise were surprised to see median wallets growing.  In fact this had to happen because players were spinning more.

To understand this look at spins vs players bucketed by rtp before and after the inflation.  The central limit theorem gives shape to two beautiful curves, but the one after the inflation will be taller and narrower.  The curve with higher spins has a higher median player rtp.

Applying the accounting identity for slot economies to just those players around the median rtp gave very precise estimates of how much median wallets should have been growing.  This leads us to the more interesting questions.  Why did players' desire for volatility decrease? and what if anything should the casino do about it?

Eventually the average bets grew in size, spins dropped down to normal levels, and median and mean wallets moved in synchronization again.  I conjecture this is a long run equilibrium condition deeply rooted in the players' tastes for volatility.  In the next post we will see more precisely how spins St relates to volatility.

Sunday, July 11, 2021

Do Hangover Effects Exist?

Kahneman and Tversky seemingly started a revolution in the 1970s culminating in 1979 with "Prospect Theory: An Analysis of Decision Under Risk" which would later be rightly rewarded with the Nobel Prize in Economics.  In the popular narrative, they challenged the old orthodoxy of rational agents optimizing expected utility when facing risky decisions.  Now that their ideas are marching towards the half century mark, it is probably appropriate to understand their critique.

It is important to realize that their theory applies more to the decision makers operating the casino than to the customers gambling.  We talk about hangover effects, because it is easier for managers to describe hangover effects than it is to talk about and measure the intertemporal substitution decisions players make when they buy more during a sale.

Every player has a budget and would prefer to spend a certain amount of money on gambling over a week.  When the casino offers a sale, the player can choose to spend more money on that day.  What we notice is that there is less money spent on average on the next day.  Is this an irrational hangover effect from players being over stimulated or is it the rational moving of money to today that would have been spent in the future?  The answer is of course some of both, so it needs to be measured.

I'll write out a model to measure the effects from the economy accounting identity, but first here are a few more empirical points.  Players expect sales, so these factor into their spending behaviors.  This means it is important to look at events not just one day to the next but also at weekly and other frequencies.  The following model is more appropriate when the variables are weekly totals rather than daily totals.  Finally to motivate the exploration, I have seen slot economies for unique reasons stop special sales and events.  Within a week the daily average spent smoothed out and rose compared to non-sale days when sales were used regularly.

In this model we again apply the equilibrium conditions of wallets staying on average constant, (Wt-Wt-1)/B= 0, and of an economy up to this point being stable, ft-1 + et-1 + pt-1 = rake. So looking at the equation for the day of the new sale,

ft + et + pt = rake (1),

we expand purchases pt = (D+d)*(X+x) = D*X + D*x + d*X +d*x.  D is yesterday's demand to buy coins in $; d is the additional demand today from the sale; X is yesterday's exchange rate of coins per $; x is the additional coins given in today's sale compared to yesterday's exchange rate.

Remember that all of these variables in (1) have been divided by total bets  Bt = Bt-1*(1+c), and we are going to find a simple relationship with the growth in bets, c.

ft-1/(1+c) + et-1/(1+c) + (DX+Dx+dX+dx)/Bt-1/(1+c) = rake (2),

is derived from (1) with the above substitutions and equilibrium conditions and reorganizing we get

ft-1/(1+c) + et-1/(1+c) + DX/Bt-1/(1+c) + (Dx+dX+dx)/Bt-1/(1+c) = rake (3),

which by definition is,

ft-1/(1+c) + et-1/(1+c) + pt-1/(1+c) + (Dx+dX+dx)/Bt-1/(1+c) = rake (4).

Imposing our equilibrium condition again,

rake/(1+c) + (Dx+dX+dx)/Bt-1/(1+c) = rake (5),

and simplifying we get

(Dx+dX+dx)/Bt-1 = c*rake (6).

We are basically done here as conceptually by renaming Dx + dX + dx as new demand in coins,

New Demand = c*rake*Bt-1 (7),

or solving for d,

d = ( c*rake*Bt-1 - x*D ) / Exchange Rate (8),

gives the equilibrium condition relating new $ demand, d, to the growth in coins bet, c.  The details of these equations will be slightly altered depending on how your sales are structured, but you are looking for equations very similar to these.

If you want to apply Kahneman's Thinking, Fast and Slow, it needs to be by looking at this equilibrium condition and inducing the players to change this equation to the casino’s advantage.







Wednesday, July 7, 2021

How to Tune a Feature

Imagine having a feature that a casino plans to turn on a few times each week.  The feature is meant to keep players engaged and give them goals, but isn't necessarily a big money mover, so that the dynamics of the economy should be mostly stable.

One way to interpret this is by observing the frequent truth of constant wallets.  In terms of the economy equation derived in the previous post,

ft + et + pt = (Wt-Wt-1)/Bt + rake,

simplifies,

ft + et + pt = rake. (1)

Where the change of wallets (W-W') = 0. ft, et and pt are free, earned and purchased credits divided by total bets, respectively.  Finally rake is the expected (1- return to player) of the casino.

The casino is going to pay out et = 2%, in an equilibrium economy with ft-1 + pt-1 = rake.  This is enough to derive a useful equation, when we realize that ft=Ft/Bt , etc, and the casino is going to require an increase c in Bets before granting the reward.  Since Bt = (1+c)Bt-1, we get from equation (1),

ft-1/(1+c) + et + pt-1/(1+c) = rake,

simplifies,

et*(1+c) = c * rake. (2)

The structure of et = k*St-1/Bt, or in words, the earned credits are equal to k times some player statistic, St-1.  This allows us to rewrite (2) as,

k*St-1/Bt*(1+c)  = c * rake. (3)

As stated above the casino targets 2% feature return, i.e.,

k*St-1/Bt = 2%. (4).

Again substituting Bt = (1+c)Bt-1, and assuming the casino uses a bet based player statistic we take St-1=Bt-1 which gives,

k/(1+c) = 2%, (5)

and,

k = c * rake. (6)

(5) and (6) are two linear equations in two unknowns, c and k, which means we can solve them.  Taking rake = 8% we determine c = 33.3% and k = 2.67%.

The importance of this result is that you can choose rtp of the feature but then you must choose either how much you want players to increase bets or how much you want wallets to change.  There is only one value of c and k consistent with 2% feature return and no change in wallets.

More generally we may want to decrease wallets in the hopes that players purchase to maintain them, etc.  Following most of the above argument but with, (Wt-Wt-1)/Bt = dw, we would get

k - rake * c = dw, (7)

or

2%/(1+c) - rake * c = dw. (8)

The following is a plot of  dw vs c from (8).


These simple equations should supplement the tuning of regularly occurring features, so that overall changes in wallets can be predicted and tracked.  Too often the casino asks the players to increase bets by what "feels right" or doesn't test at all against the economy goals, with a resulting falling apart of the equilibrium.  What is necessary is to make explicit rake, feature return and desired change in wallets.  From there, a model that specifies "bet ask" can be identified.

Friday, July 2, 2021

Income Accounting For Social Slots


Many of us are probably familiar with the accounting equation of national income, Y = C + I + G + NX, which relates national income to a country's expenditures in the form of consumption, investment, government spending and net exports.  Most of us have at least heard of GDP in which Y is empirically measured at monthly, quarterly or annual frequencies.  A few of us have had the pleasure of seeing this simple equation used to develop and debate deep theorems in economics and public finance.  Lord Keynes himself, Marxian economist Kalecki, and Nobel laureate Simon Kuznets all worked their theories out of this common framework. It is about time we develop a similar framework for the tokenized economies of social slots.

Due to the hard work of engineers and data science, we often have complete daily information on individual players that allows us to connect all the relevant variables at a high level.  We can begin with an individual player and build up from there. A player starts her day with Wt-1 coins in her wallet.  Over the course of the day she is given F free coins, earns E coins through engagement, purchases P coins and wins Win amount of coins.  She will have bet B coins throughout her day and holds Wt coins at the end of the day when she stops playing.  The change in her daily wallets Wt-Wt-1 combined with her total bets must equal all the inflows the player accumulated:

F + E + P + Win = Wt-Wt-1 + B.

Basically, a player can choose to keep coins in her wallet or bet coins, but only from the stock pile of coins she had at the beginning of her session, from the coins the game gives her, or from the coins she wins by betting.  This equation holds for every individual player, but also holds when players are summed up.  So we can take this equation as an aggregate accounting identity when considering the economy as a whole or large subgroups of the economy.

After aggregating, let's make a few more transformations to make it more useful.  Subtracting total wins from bets is called RAKE, but let's also divide all variables on both sides of the equations through by bets:

F/B + E/B + P/B = (Wt-Wt-1)/B + B/B - Win/B,

or,

f + e + p = (Wt-Wt-1)/B + 1 - Win/B.

The lower case letters are shorthand for free credits normalized by bets (f = F/B), etc.  But maybe it doesn't look too helpful yet?  Well, ask any games mathematician about Win/B.  For large numbers of players, although volatile, Win/B will on average equal the return to player RTP.

f + e + p = (Wt-Wt-1)/B + 1 - RTP,

or,

f + e + p = (Wt-Wt-1)/B + rake.

In this last equation, rake means the rate of coins lost to the house when coins are bet on the slot machines.  To summarize in words: adding free, earned and purchased coins normalized by total daily bets equals the change in wallets normalized by bets plus casino's rate of rake.  All of these variables are likely already stored somewhere. They may even be sitting on the same Tableau dash, waiting for you to precisely and accurately connect them. An immediate lesson we can learn from these equations is that chance wins in machines will push plenty of noise into the other variables.

Let's analyze a basic scenario to understand how to really use the equation.  For a month's worth of data you look at all these variables at daily frequencies.  You have a problem, purchases have fallen so much that p has fallen over time.  You notice wallets stayed constant so (Wt-Wt-1)/B = 0, and of course your economy is tuned to 92% RTP so the equation is simply:

f + e + p = 0.08,

or,

F + E + P = B*(0.08).

If purchases decreased, by pure accounting, this could have been because free and/or earned inflows increased, total bets decreased or some combination.  What is important is that this is a very precise equation and scaling the effects of inflows on bets by RTP or vice versa is often neglected.

If total bets also stayed constant, then the change in purchases was likely caused by an increase in inflows.  If however purchases fell such that total inflows fell 10%, we know that any compensating rise in free and earned credits did not fully offset the drop in purchased credits and total bets also fell 10%.  But, if we intervened by changing RTP, things get more complicated! As an exercise, assume RTP was tightened 1%, what happened to total bets to have balanced the equation?  

True empirically driven economics begins by being able to look at these scenarios, reducing them down to accounting truths, postulating how players are financing their changes in behavior and making bold educated guesses as to how all the variables will play out given your interventions. There is no reason for data analysts, product managers, or economists to just wing it when guessing how much of a change in RTP they should use, if they should use it at all.

In subsequent posts, I hope to explore these identities in relation to common industry practices like price inflation, periodic sales and making earned credits a function of past bets or wallet sizes.

Saturday, January 31, 2015

Cross Section of Nevada Slot Regions

Applying the aggregated Nevada time series model to the individual regions provides confirmation of the same general findings in the previous post.  We are also able to group regions by qualitative findings.

The following table suggest one possible interpretation using three qualitative groups.
The R^2 value is the amount of variation explained by our linear model.  Accordingly, within each group, I rank by the region’s R^2.  The higher the R^2, the better our model explained the actual data of the region.  The first thing to note is that the grouping is a pretty good indication of average explained variation.  So, what are the characteristics of each group?


Group 1:  All of these regions have characteristics that match the aggregated model.  All show a long run tightening hold of on average between 1 – 2.5 hundredths of a % per month.

Each member of Group 1 has a monthly oscillating pattern that can be described by two months of data. The average holds are pretty tight.  Finally all show a significant loosening in December.

Group 2:  Reno and Elko stand apart as they have on average a looser hold than their Group 1 counterparts, and show no long run change in monthly hold.  Instead of an oscillating pattern, movements in hold tend to reiterate themselves.  The December loosening is milder in these regions.

Group 3:  NSLT and Mesquite are the only regions that show a tightening in December.  This is most likely the result of the bad fit of the model.  With them SSLT shows a long run loosening in hold.  Their various other coefficients do not lead to any obvious interpretation.  The lack of competition in these regions (relative to the bigger gambling destinations) probably leads to different strategies, exposure to shocks and small sample problems.  An ARCH type model looks like it would be a better fit.

Importantly, the regions when analyzed under the aggregated model do not dispute recession hold tightening.  In fact most of the regional models, even Mesquite, show higher than average tightening during that time. Under the lens of the tightening hypothesis, Mesquite’s peculiarities are likely brought on by the recession.


As far as statistical methodology, there are still places I may have tripped.  Efficient estimators of the variance structure should be explored.  Also, since I ran the regressions one at a time, I could run a panel regression for better estimates.