Problem with matrix function output (Q learning, Calvano et al. 2021)
Show older comments
Hello !
I'm currently working on the Q learning algorithm similar to the one presented in Calvano et al. 2021 (AER).
As a part of preliminary work, I want to produce a distribution table similar to the one I attached below.
The idea is simple. I have a function which gives prices and profits for 2 market makers depending on multiple parameters. More particularly, I want it to vary in alpha (2.0:0.1:4.0) and beta (0.04:0.001:0.06) and fix other parameters at the begining. Then, having a matrix of average values (my function 'fn' gives average prices and profits) and using imagesc(), it would be easy to obtain the desired results. The problem is that the code is not working.
Here is what I have at the moment :
beta0=0
n=10000
T=1000
[P,Profit]=fn(2.0:0.1:4.0,0.04:0.001:0.06,beta0,n,T); % I don't know how to index the profits depending on alpha and beta in order to have a clear matrix later.
Matr=append(Profit(:,1)); % Here I put Profit(:,1) because I'm verifying first the profits of the first market maker. But the 'append' function is clearly a wrong idea.
a=(2.0:0.1:4.0)
b=(0.04:0.001:0.06)
imagesc(b, a, Matr);
set(gca, 'YDir', 'normal');
xlabel('beta');
ylabel('alpha');
colorbar
I've already spent hours looking for an answer. It's the first time I use matlab which makes it difficult not only to optimize my code (to make it less time consuming) but also to make it work. I would be very greatful for any help. Thank you !!

4 Comments
Walter Roberson
on 14 May 2021
Are you thinking in terms of selecting the first alpha and for it, using all of the beta values, and appending the results to a matrix; and then going on to the second alpha and for that using all of the beta values, and appending the results to a matrix, and so on, ending up with a matrix that is length(alpha) by length(beta) ?
If so then possibly your fn() is already producing that kind of output. We would need to see the code for it to be sure.
Your 2.0:0.1:4.0 and 0.04:0.001:0.06 each happen to have 21 elements, so depending on how your fn is working, it is also possible that instead of producing a 21 x 21 output, that it would produce a 1 x 21 output... depends how it was written.
Olena Bogdan
on 14 May 2021
Walter Roberson
on 14 May 2021
Edited: Walter Roberson
on 14 May 2021
Where does your code use alpha ?
Also your f1 function appears to be truncated.
Olena Bogdan
on 14 May 2021
Accepted Answer
More Answers (0)
Categories
Find more on Parallel Computing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!