Smooth Signal Correlation

Hello
I wanted, to smooth data signal.

For example, using mean

y[1]=(a[1]+a[2])/2

it is

y[1]=0.5*a[1]+0.5*a[2]
y[2]=0.5*a[3]+0.5*a[4]

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

y[2]=0.235*y[1]

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” ?

Background:
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

y[1]=x1[1]*data[1]+x1[2]*data[2]

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    )
    end)



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


optimize!(model)
print(objective_value(model))
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]?

2 Likes

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