Hello all,
I'm facing difficulty in fitting the data.
The red ones are from the data set, and I want to fit that as like blue one (Experimental Data). How can I do that. I have also attached the data set for your reference.
Thank You.

댓글 수: 2

Sam Chak
Sam Chak 2023년 7월 29일
What is the mathematical function of the blue curve? Is it a skewed normal distribution function?
Can you also suggest some candidate functions for fitting into the red data? Look up some Kernel functions.
Red data seems to have discontinuities at multiple intervals. Is it acceptable to have a piecewise function to fit the data?
Prajwal Magadi
Prajwal Magadi 2023년 7월 29일
The blue curve is also a data set from an experimental obervation.
The red data is from the simulation.
And I have no idea of the function type of blue data.

댓글을 달려면 로그인하십시오.

 채택된 답변

Sam Chak
Sam Chak 2023년 7월 29일

1 개 추천

Not sure if this is what your want. But you can try finding the best math function to fit.
data = load('curve_fit.mat');
x = data.theta_degree';
y = data.x';
skewEqn = 'a/(sqrt(2*pi))*exp(- b*(x - c)^2)*((1/2)*(1 + erf(e*(x - c)/sqrt(2)))) + d';
fo = fitoptions('Method', 'NonlinearLeastSquares',...
'Lower', [ 0, 0, 5, 0, 0.1],... % {a, b, c, d, e}
'Upper', [100, 1, 20, 10, 1.0],...
'StartPoint', [50 0.5 10 5 0.5]);
ft = fittype(skewEqn, 'options', fo);
[yfit, gof] = fit(x, y, ft)
yfit =
General model: yfit(x) = a/(sqrt(2*pi))*exp(- b*(x - c)^2)*((1/2)*(1 + erf(e*(x - c)/sqrt(2) ))) + d Coefficients (with 95% confidence bounds): a = 85.15 (84.38, 85.93) b = 0.003494 (0.003423, 0.003564) c = 7.162 (7.116, 7.209) d = 2.461 (2.241, 2.681) e = 0.3845 (0.3752, 0.3937)
gof = struct with fields:
sse: 9.7227e+04 rsquare: 0.9063 dfe: 9995 adjrsquare: 0.9062 rmse: 3.1189
plot(yfit, x, y)
grid on, xlabel('\theta'), ylabel('x')
legend('Data', 'Fitted Skew Dist Fcn')

댓글 수: 2

Prajwal Magadi
Prajwal Magadi 2023년 7월 29일
Thank you Sam.
Sam Chak
Sam Chak 2023년 7월 29일
@Prajwal Magadi, Don't mention it. Have a nice weekend!

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Alex Sha
Alex Sha 2023년 7월 29일

1 개 추천

@Prajwal Magadi, one more function:
Sum Squared Error (SSE): 75571.6557870726
Root of Mean Square Error (RMSE): 2.74902993412354
Correlation Coef. (R): 0.962878352853849
R-Square: 0.927134722394541
Parameter Best Estimate
--------- -------------
y0 3.57509887406416
a 10210313.7484567
xc 17.1109591760412
w1 18.7010167618592
w2 -1.38399464317597
w3 -1.49504622174935

댓글 수: 3

Sam Chak
Sam Chak 2023년 7월 29일
편집: Sam Chak 2023년 7월 29일
Nice one, @Alex Sha. 👍
Can you advise how you selected the candidate as the product of the logistic function and its scaled reflection?
By the experience of seeing hundreds of different single-hump skewed distribution functions?
x = linspace(-10, 20, 30001);
y1 = 1./(1 + exp(- (x - 1)));
y2 = 1 - 1./(1 + exp(- (x - 1)/5));
y = y1.*y2;
plot(x, y1, 'linewidth', 2, 'color', '#7c98c3'), hold on
plot(x, y2, 'linewidth', 2, 'color', '#e5ab45'),
plot(x, y, 'linewidth', 2, 'color', '#abc564'), grid on
xline(1, '-.', {'x = 1'})
legend('logistic fcn', 'scaled reflection', 'skewed fcn')
xlabel('x')
Alex Sha
Alex Sha 2023년 7월 29일
Hi, your data chart looks like peak-type function chart, so just try some typical peak functions, "Asym2Sig" function, shown above, gives more better outcomes.
Sam Chak
Sam Chak 2023년 7월 29일
Hi @Alex Sha, thanks for sharing the information about the Asymmetric Double Sigmoidal function. I don't have Origin Pro, and I have never seen many of those functions before.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

제품

릴리스

R2023a

질문:

2023년 7월 29일

댓글:

2023년 7월 29일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by