Fitting the Cauchy pdf curve to a set of approximating data
19 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have some sampled data
and
from a signal to which I would like to best-fit the function describing the pdf of the Cauchy distribution
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1065510/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1065515/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1065520/image.png)
In this problem γ is a known small positive constant (ideally set as close to 0 as not cause problems in the computation). The ultimate objective is to obtain the estimate
of
which best achieves the fit.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1065525/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1065530/image.png)
I am working on the least-squares solution to this, but I also wanted to try the Matlab curve-fitting function 'fit'. I would appreciate some help in understanding the syntax required for the custom curve form (which I would implement in a Matlab function file) to be passed to the function 'fit' so that the parameter ρ is the focus of the fitting effort.
For those who have kindly got this far in this post and are interested in to know a little more ... this is essentially a matched-filter problem for which I'm sure there are also Matlab solutions.
0 comentarios
Respuestas (1)
Brahmadev
el 8 de Sept. de 2023
Hi,
I understand that you would like to fit a custom curve c(x) using the data you have sampled "x" and "q". You can use the code given below to find the value of "rho" which best fits the curve "c".
% Here I have used some sample values for "x" and "q":
x = [0.81;0.91;0.13;0.91;0.63;0.098;0.28;0.55; ...
0.96;0.96;0.16;0.97;0.96];
q = [0.17;0.12;0.16;0.0035;0.37;0.082;0.34;0.56; ...
0.15;-0.046;0.17;-0.091;-0.071];
% Calling 'fittype' for the pdf of the Cauchy distribution written in 'testing_cauchy' function.
ft = fittype("testing_cauchy(x, rho)");
f = fit(x,q,ft) % This command will output the value of all fitting parameters (rho in our case)
% with 95% confidence bounds
The following function should be in a MATLAB function file on the path.
function y = testing_cauchy(x, rho) % implementation of cauchy function, all other variables are treated as fitting parameters
gamma = 0.001; % change according to usage
y = zeros(size(x));
for i= 1:length(x)
y(i) = gamma/(((x(i)-rho)^2+gamma^2)*pi);
end
Hope this helps!
0 comentarios
Ver también
Categorías
Más información sobre Interpolation en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!