Open ttompost opened 4 years ago
Hi Tea, I am currently traveling but will be back next week. I will have a look at your code and send you some comments. If it helps, we can also set up a zoom meeting to discuss the issues you are having.
@thethea I had a quick look at your code. The calculation of the gradient of the log-likelihood is required to find the solution of the LNP model (as it has a unique optimum). The function value is actually not essential but helps the optimization routine (minimize function) to adjust the step size which considerably speeds up the optimization.
It seems that your LNP implementation is almost there. Think about which terms do not depend on lambda and drop those as they do not affect the location of the optimum (and the gradient). Then generate some data with the provided functions and estimate the model parameters of the model by plugging the data into your "maxloglike" function. Note that you will need to pass the data to your functions for computing the log-likelihood and the derivative. The "minimize" function has an extra "args" keyword argument that allows you to do this. If "S" is your stimulus design matrix and "r" the spike counts, then you can use "minimize(...., args=(S, r))" to pass them to your functions. The first argument that minimize will pass to your functions is always the current parameter vector so "S" and "r" will be the 2nd and 3rd argument, respectively. Have a look here for an example: https://stackoverflow.com/questions/43017792/minimize-function-with-parameters
Maybe have a try and let me know if this resolves your problems with the assignment.
Dear @arnefmeyer
I am struggling with understanding the second part of Assignment 5 (Neural coding), so I thought you could help me. I have read the review paper which you suggested and watched your Loom tutorial multiple times, however, my intuition in current field is quite underdeveloped. Although, I am very interested in the topic and I would like to understand the basics by solving this assignment fully.
There are multiple steps in second part of the assignment. I get that I have to calculate log-likelihood (however, I am not getting the purpose), gradient (I am also quite unfamiliar with idea behind this) and then use those two when searching for maximal likelihood. Then I guess I am to test my implementations on real data, for which I have separated spectrogram stimulus in history windows and made stimulus matrix as you suggested, but I can not seem to understand how do I get the response vector? My code so far can be found here.
My question is actually more of a general nature. The struggle is coming from trying to get the sequence of events which need to happen: how/when do I use which functions, what parameters do I need and how to get those? Or (even more banal): what to do first, next and last?
Thank you in advance, Tea