Identify rule that governs pattern in series.
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Jake
el 9 de Jul. de 2023
Respondida: Jake
el 14 de Jul. de 2023
I have a series of terms in a sequence and need to identify the rule that produces it. I know it is based on a damped harmonic oscillator but I am not sure which formula governs the interval. Here is the string, it is the interval rates in seconds: (108, 88, 92, 76, 80, 68, 64, 56, 40, 32, 8, 8) the closest I have come is: D_n = Asin(Bn + C)exp(-Dn) + E
A = Amplitude of the wave (could be around 28, as you noted that the sequence never went more than 28 in any direction) B = Frequency of the wave (which affects how “quickly” the wave oscillates - this could be tweaked to match the observed pattern) C = Phase shift of the wave (could potentially be 0 if the wave starts at its peak) D = Damping coefficient (this affects how quickly the oscillations decay - would need to be chosen to match the decay observed in the sequence) E = Equilibrium position (which would be 8, as the sequence oscillates around 8)
7 comentarios
Walter Roberson
el 9 de Jul. de 2023
Degree 9 polynomial looks decent R^2 when you center and scale, but any polynomial struggles with two adjacent values the same.
John D'Errico
el 10 de Jul. de 2023
Editada: John D'Errico
el 10 de Jul. de 2023
A 9th degree polynomial would be a literally insane fit. If it does fit well, that would be based merely on R^2. But R^2 does not measure what the curve does between the data points. And with 12 data points, and 10 parameters to estimate? It will be purely chasing noise. R^2 does not measure if the fit makes any sense at all.
n = (1:12)'; % (I assume that this is implied.)
D_n = [108, 88, 92, 76, 80, 68, 64, 56, 40, 32, 8, 8]';
nhat = (n - mean(n))/std(n);
P9 = fit(nhat,D_n,'poly9')
plot(P9,nhat,D_n,'o')
As I said, the degree 9 polynomials is a bad thing to do, even to bad data. Yes. It fits the data points reasonably well, but that is all one can say.
Respuesta aceptada
Sam Chak
el 10 de Jul. de 2023
Hi @Jake
If you are 100% sure that the data is the response of a damped harmonic oscillator, then you should fit it using the model of a damped harmonic oscillator, despite the possibility of the data being corrupted by noise. A sensible model of an underdamped harmonic oscillator is given by:

n = (0:11)';
D_n = [108, 88, 92, 76, 80, 68, 64, 56, 40, 32, 8, 8]';
% proposed damped harmonic oscillator model
modelfun = @(F,n) F(1).*exp(-F(2).*n).*(sin(F(2).*n) + cos(F(2).*n)) + F(3);
% initial values
beta0 = [108 0.1 1];
% fit nonlinear regression model
mdl = fitnlm(n, D_n, modelfun, beta0)
% predict the outputs of the model
D_n_predicted = predict(mdl, n);
% compare between the data and the fitted model
plot(n, D_n, '.', n, D_n_predicted), grid on, xlabel('n'), ylabel('D_n')
legend('data', 'fitted model')
% predict the steady-state of the model
t = linspace(0, 120, 1201);
y = predict(mdl, t');
plot(t, y, 'linewidth', 1.5), grid on, xlabel('n'), ylabel('D_n')
title('Prediction of the steady-state')
Based on the model and the plot, it is predicted that the damped harmonic oscillator will settle at
. If this is not the case, then you should obtain more data points, at least until the harmonic oscillator reaches steady-state.

2 comentarios
Walter Roberson
el 10 de Jul. de 2023
The original model posted was in terms of parameters A B C D E
You have
modelfun = @(F,n) F(1).*exp(-F(2).*n).*(sin(F(2).*n) + cos(F(2).*n)) + F(3);
which is A*exp(-B*n)*(sin(B*n) + cos(B*n)) + C -- only three parameters.
Sam Chak
el 10 de Jul. de 2023
Isn't it true that we should simplify the problem sufficiently so that it becomes solvable and that the solution will provide insight into the original problem?
In other words, even though the two functions
and
may appear different, mathematically they produce the same outputs. By simplifying the problem, we can reduce the number of parameters to determine from five to just three, without sacrificing the behavior of the solution.


After all, @Jake mentioned the damped harmonic oscillator, and I provided the link that shows the proposed model for his reference. Additionally, I suggested obtaining more data points because it doesn't seem that the oscillator has truly reached the steady state (equilibrium) at 8, considering that the data is corrupted by noise.
Más respuestas (1)
Ver también
Categorías
Más información sobre Linear and Nonlinear Regression 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!