Search models with learning VII

Hi all, I am trying to replicate the code of the search models with learning with Matlab, the main part was ok, but I get stuck in the appendix A, I can’t get the same figure in Matlab, I think the problem is that I don’t know Python so, it is not easy for me to translate it. Can someone help me and explain me what the code does in this appendix?

Thank you so much,