Jim Killingsworth

High­er Or­der Poly­no­mi­al Ap­prox­i­ma­tion

This is an ex­ten­sion of one of my ear­li­er posts on poly­no­mi­al ap­prox­i­ma­tions. Pre­vi­ous­ly, I showed how to find ap­prox­i­mate so­lu­tions to the weight­ed coin toss prob­lem us­ing first, sec­ond, and third or­der poly­no­mi­als to de­scribe the weights of the bi­ased coin­s. In this post, I demon­strate a gen­er­al­ized method for ap­ply­ing this tech­nique us­ing high­er or­der poly­no­mi­al­s.

Gen­er­al­ized Method

As­sume we’re us­ing a mod­el of the coin toss game with an ar­bi­trary num­ber of coin toss events per round. The pur­pose of this tech­nique is to use a poly­no­mi­al of an ar­bi­trary de­gree to de­scribe the weights of the bi­ased coin­s. Giv­en the de­gree of the poly­no­mi­al, let’s de­fine the fol­low­ing:

Figure 1

This num­ber tells us how many co­ef­fi­cients are in our poly­no­mi­al. It al­so de­fines the size of a ma­trix we will use to com­pute the val­ues of the co­ef­fi­cients. Let’s as­sume this num­ber is small­er than the num­ber of coin toss events:

Figure 2

Here is what our poly­no­mi­al func­tion looks like in ex­pand­ed for­m:

Figure 3

Here is what it looks like us­ing a more com­pact no­ta­tion:

Figure 4

Re­call from the last few posts the it­er­a­tive pro­ce­dure we used to find ap­prox­i­mate so­lu­tions to the coin toss prob­lem us­ing poly­no­mi­als to rep­re­sent the weights of the bi­ased coin­s. What we need to do now is find the val­ues of the co­ef­fi­cients based on a sub­set of the weights of the bi­ased coin­s. Let’s use the fol­low­ing no­ta­tion to rep­re­sent this sub­set as a vec­tor:

Figure 5

This sub­set of the weights rep­re­sents a guess for a par­tic­u­lar it­er­a­tion of the op­ti­miza­tion process. It is a set of ar­gu­ments we can use to find the cor­re­spond­ing co­ef­fi­cients. And know­ing the co­ef­fi­cients, we can then com­pute the re­main­ing weights based on the poly­no­mi­al. Let’s use the fol­low­ing no­ta­tion to rep­re­sent the co­ef­fi­cients as a vec­tor:

Figure 6

Once we know the val­ues of the co­ef­fi­cients, we can com­pute the val­ues for the re­main­ing weights and then cal­cu­late the val­ue of the cost func­tion. We re­peat this process at each it­er­a­tion to find in­cre­men­tal­ly bet­ter so­lu­tion­s. But how do we com­pute the val­ues of the co­ef­fi­cients? Con­sid­er the fol­low­ing ma­trix:

Figure 7

With this ma­trix, we can set up a sys­tem of equa­tion­s. The ma­trix mul­ti­plied by the co­ef­fi­cient vec­tor is equal to the ar­gu­ment vec­tor rep­re­sent­ing a sub­set of the weights of the bi­ased coin­s. Here is this re­la­tion­ship ex­pressed as a ma­trix equa­tion:

Figure 8

Thus, we have a sys­tem of equa­tion­s. Us­ing the in­verse of the ma­trix, we can re­arrange the ma­trix equa­tion above to ex­press the co­ef­fi­cients in terms of the in­puts de­pict­ing a sub­set of the weights of the bi­ased coin­s:

Figure 9

Once we have com­put­ed the co­ef­fi­cients, we can use the poly­no­mi­al to com­pute all of the weights of the bi­ased coins in the same man­ner as de­scribed in the last few post­s. Note that we on­ly need to com­pute the ma­trix and its in­verse one time. They do not need to be re­com­put­ed for each it­er­a­tion of the op­ti­miza­tion process. In the ex­am­ples that fol­low, we will use the Nelder–Mead method in­stead of the hill climb­ing method as the it­er­a­tive method to find the most op­ti­mal so­lu­tion.

Ex­am­ple with Sec­ond Or­der Poly­no­mi­al

To il­lus­trate how this tech­nique work­s, let’s do an ex­am­ple us­ing a sec­ond or­der poly­no­mi­al. This ex­am­ple is sim­i­lar to an­oth­er ex­am­ple il­lus­trat­ed in a pre­vi­ous post. We’ll start with the fol­low­ing de­f­i­n­i­tion:

Figure 10

Here is what our sec­ond or­der poly­no­mi­al func­tion looks like:

Figure 11

Here is the ma­trix for a sec­ond or­der poly­no­mi­al:

Figure 12

Here is the in­verse of the ma­trix:

Figure 13

And here is how we ex­press the co­ef­fi­cients in terms of the weight­s:

Figure 14

Con­sis­tent with ex­am­ples from some of the pre­vi­ous post­s, let’s use the fol­low­ing prob­a­bil­i­ty mass func­tion as the tar­get dis­tri­b­u­tion we want to find an ap­prox­i­ma­tion for:

Figure 15

Here is the so­lu­tion found af­ter 161 it­er­a­tions:

Figure 16

Here is the val­ue of the cost func­tion at the most op­ti­mal point:

Figure 17

As you can see, based on the val­ue of the cost func­tion at the most op­ti­mal point, this is not an ex­act so­lu­tion. But it is still a pret­ty good ap­prox­i­ma­tion. And this so­lu­tion match­es the one found in the oth­er ex­am­ple.

Ex­am­ple with Sixth Or­der Poly­no­mi­al

To demon­strate the ca­pa­bil­i­ties of this ap­prox­i­ma­tion tech­nique, let’s show­case an­oth­er ex­am­ple. For this ex­am­ple, let’s use a sixth or­der poly­no­mi­al. Us­ing the same ap­proach as be­fore, we’ll start with the fol­low­ing de­f­i­n­i­tion:

Figure 18

Here is what our sixth or­der poly­no­mi­al func­tion looks like:

Figure 19

To be con­sis­tent with the ex­am­ple in the pre­vi­ous sec­tion, we’ll use the same tar­get dis­tri­b­u­tion. Here is the so­lu­tion found af­ter 1,308 it­er­a­tions:

Figure 20

Here is the val­ue of the cost func­tion at the most op­ti­mal point:

Figure 21

Based on the val­ue of the cost func­tion at the most op­ti­mal point, this ap­pears to be an ex­act so­lu­tion. Ap­ply­ing this tech­nique with fourth and fifth or­der poly­no­mi­als al­so yields seem­ing­ly ex­act so­lu­tion­s. And it does so with few­er and less com­pu­ta­tion­al­ly ex­pen­sive it­er­a­tions. It is not clear to me what min­i­mum de­gree of a poly­no­mi­al is re­quired to find an ex­act so­lu­tion in the gen­er­al case when there is an ar­bi­trary num­ber of coin toss events.

Ac­com­pa­ny­ing source code is avail­able on GitHub.

Com­ments

Show comments