Finding the inflection point of a sigmoid function
16 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Iddo Weiner
el 18 de Dic. de 2017
Hi, here's my function:
% define params
p1 = 0.0389;
p2 = 1.9158;
p3 = 162.4272;
p4 = 0.012;
% simulate the function
syms x
f = p1+(p2-p1)/(1+10^((p3-x)*p4));
fplot(f,[1 245])
Now, I would like to find the inflection point (I manually drew where I roughly expect it to be).
Here's what I was trying to do:
double(solve(f,'MaxDegree',3))
but I get this:
ans = 2.1394e+01 - 1.1370e+02i
Which means that there is no real inflection point... Where's my mistake?
Thanks in advance
Iddo
0 comentarios
Respuesta aceptada
Star Strider
el 18 de Dic. de 2017
Try this:
p1 = 0.0389;
p2 = 1.9158;
p3 = 162.4272;
p4 = 0.012;
% simulate the function
syms x
f(x) = p1+(p2-p1)/(1+10^((p3-x)*p4));
inflpt = vpasolve(diff(f,2) == 0); % Calculate Inflection Point
figure(1)
fplot(f,[1 245])
hold on
plot(inflpt, f(inflpt), 'pr', 'MarkerSize',10, 'MarkerFaceColor','g')
hold off
4 comentarios
Más respuestas (2)
Roger Stafford
el 18 de Dic. de 2017
Editada: Roger Stafford
el 18 de Dic. de 2017
The inflection point occurs at x = p3. You can show it by using the symbolic 'diff' to find the second derivative of f with respect to x and finding the x that makes it zero. That occurs when 10^((p3-x)*p4)) is equal to 1 which forces x to equal p3.
Lalitesh
el 30 de En. de 2023
Editada: Torsten
el 30 de En. de 2023
Hi,
I hope you have solved your inflection point problem. Could you please suggest me how to find inflection point in the given below case ?
y = [4941.325135
5373.592952
5341.265151
5109.495841
5164.985178
4910.347906
5036.098753
5210.505118
4897.930074
5303.555152
5059.674066
5294.250906
5045.080549
5139.444791
5184.016273
4989.822273
4879.351675
5037.299623
5193.317198
5126.702477
5114.934361
5163.894699
5250.845909
5236.142352
5425.261686
5026.998422
5181.941373
5043.063249
5226.955717
5045.126978
5285.330253
5147.00929
5089.199187
5433.585096
5259.022363
5135.878393
5075.663506
5068.604444
5240.425345
5013.836134
5235.932975
5293.152198
5362.597535
5288.109111
5034.519472
5095.714828
5267.142594
5168.69091
5050.240489
4921.738751
];
x = [-0.013607785
0.765345224
1.10289259
1.029090207
-0.022931512
-0.017396819
-0.074107114
0.769494196
2.98E-06
0.920557852
0.738470623
-0.025517765
0.820330824
0.561636238
1.02437854
0.748933493
-0.024258105
0.172846729
-0.040833861
1.015883315
0.961682273
0.974008018
-2.782219696
1.02138985
0.556479342
0.411214807
1.056242842
-3.368250299
1.094017765
1.128149932
-0.040686495
-0.013525985
-0.028379761
0.979391037
0.662479735
1.127613475
0.488222296
-0.067298217
1.022925141
-0.119633187
1.04065864
0.286375511
1.195491684
0.957996374
1.103174243
1.049128867
1.080726806
0.99141825
1.198772497
0.864385088
];
fn = @(b,x) b(5).*(b(1) + b(2)./(1 + exp(-b(3).*(x-b(4))))).^(b(6)) % Sigmoid Function (Objective Function)
SSECF = @(b) sum((y - fn(b,x)).^2); % Sum-Squared-Error Cost Function
B0 = [-0.1; -0.1; -5; 0.1; 0.8; 10]; % Initial Parameter Estimates
[B,SSE] = fminsearch(SSECF, B0) % Estimate Parameters (B), Return Sum-Squared Error (SSE)
xp = linspace(min(x), max(x))
figure(1)
plot(xp, fn(B,xp), '-r')
hold on
plot(x,y,'o')
hold off
5 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!