Skip to content
Advertisement

Tag: nested-function

How to write a function to fit data to a sum of N Gaussian-like peaks without explicitly defining the expression for every possible N?

I am trying to fit a progression of Gaussian peaks to a spectral lineshape. The progression is a summation of N evenly spaced Gaussian peaks. When coded as a function, the formula for N=1 looks like this: where A, e0, hf, S and fwhm are to be determined from the fit with some good initial guesses. Importantly, the parameter i

Why aren’t python nested functions called closures?

I have seen and used nested functions in Python, and they match the definition of a closure. So why are they called “nested functions” instead of “closures”? Are nested functions not closures because they are not used by the external world? UPDATE: I was reading about closures and it got me thinking about this concept with respect to Python. I

Advertisement