Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Given an n-dimensional function, can I use FindFit to produce an approximate (n-k)-dimensional function?
Here is a simplified illustration of what I am trying to do. I have $$f(x,a,b,\mu,\sigma) = \frac{g(x,a)\,g(x,b)}{\sigma\sqrt{1+x^2}}\phi(\frac{x-\mu}{\sigma})$$ where $\phi$ is the $\mathcal{N}(0,1)$ density, $a,b\in[-1,1]$, $\mu\in\mathbb{R}$, $\sigma\in\mathbb{R}^{*+}$ and $$ g(x,a) = \max(0, -ax+\sqrt{1-a^2}). $$ Here is the code to build such a function with Mathematica:

ND[x_]:= Exp[-x^2/2] / Sqrt[2*Pi]
G[x_, a_] := (-a*x + Sqrt[1 - a^2]) * UnitStep[(-a*x + Sqrt[1 - a^2])];
F[x_, a_, b_, m_, s_] := G[x, a] * G[x, b] * ND[(x - m)/s] / (s * Sqrt[1 + x^2])

I would like to approximate $f$ with the following Gaussian function $$g(x,\alpha,\beta,\gamma) = \frac{\alpha\gamma}{\sqrt{\pi}} \exp(-(\gamma x-\beta)^2)$$ where $\alpha,\beta,\gamma$ are functions of $a,b,\mu,\sigma$. So if I create a table

Flatten[Table[{x, m, F[x, a, b, m, s]}, {x, -15, 15}, {a, -1, 1}, {b, -1, 1}, {m, -1, 1}, {s, 0.125, 2, 0.125}]] 

can I use FindFit to yield $\alpha, \beta, \gamma$ which will approximate $f$ ?

share|improve this question
    
Offhand I would think so. Did it not give you reasonable results? Note: you will want to include values of all parameters, e.g. a,b,s as well as x,m, in your data list. If you were getting error messages, rather than a result, that could be the cause. –  Daniel Lichtblau Jun 13 '13 at 2:51
    
It does seem like the basic idea is OK. One thing is that you have a rather sparse sampling of your space. Since everything is spaced in integers, you only have 3 different values of a, b and m. I would suspect you would do better to have a denser sampling, for instance, {a,-1,1,0.1}. –  bill s Jun 13 '13 at 3:26
    
You are absolutely right about the sampling density issue. But assuming I have an adequate table, how do I use it in FindFit ? I guess it would be something like FindFit[%, {alphagammaExp[-(gamma*x - beta)^2]/Sqrt[Pi]}, {alpha, beta, gamma}, {x,a,b,m,s}] but how am I supposed to inform Mathematica that alpha, beta, gamma are functions of a,b,m,s ? –  user49546 Jun 13 '13 at 15:34

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.