Smooth Signal Correlation

I wanted, to smooth data signal.

For example, using mean


it is


But in specific way, that new signal (y), need to have some attributes:
for example, linear relationship


I tried other obj function with jump ipopt nlexpression, but optimization says always optimal solution found 0 in 1 step

Is there a way to compose original signal into new one containing “required atributes” ?

In R, there is function decompose, which create vector cotaining seasonality, then remainder=original vector-seasonality. Problem is, reminder has sometimes poor autocorrelation, which can leads to even more non-smooth signal, than original .
Similar, smoothing data via mean-ing sometimes results in smooth vector, but if it contains poor autocorrelation, smoothed signal is “nonstructural”
I was wondering, if it is possible to calculate/model similiar tasks in julia including customization.

Thanks alot

Can you provide a reproducible example of your code?

1 Like

hi mr. odow, yes gladly: :leaves:

data - vector of floats

new signal is


attribute (obj function) is

maxumize sum
tanh(x2[1]*y[i-1]) * y[i]

complex goal is
tanh(x2[1]*y[i-1]+x2[2]*y[i-2]+ ... ) * y[i])

so it is simplified, but its based on good core

using JuMP
using Ipopt

model = Model(Ipopt.Optimizer)

S=2 #
D=3 #line

@variable(model, x1[1:S])
@variable(model, x2[1:D])

@NLexpressions(model, begin
        y[i=1:3000], sum(data[2*(i-1)+1+j]* x1[j+1] for j=0:1    )

         sum( tanh(x2[1]*y[i]    ) *y[i+1]            for i = 3:100   )  #just for 100 points

1 Like

Ipopt assumes the problem is convex, so it will stop when it finds a local minima/maxima. This problem has a local maxima at the default starting point x1 = x2 = 0.

You can try different starting points:

@variable(model, x1[1:S], start = 1.0)
@variable(model, x2[1:D], start = 1.0)

But I think a bigger issue is that your formulation doesn’t seem correct.

Why max? Can’t I just make the objective arbitrarily big by increasing y[i]?


Yes. I forget to mention
data is similiar to random floats around 0 (like random function - sum is 0, no autocorrelation allowed

That start parameter is helpful :leaves: thank you