# Need advice on pecuzal\_embedding and RecurrenceMatrix

**URL:** https://discourse.julialang.org/t/need-advice-on-pecuzal-embedding-and-recurrencematrix/119257
**Category:** New to Julia
**Tags:** time-series, dynamical-systems
**Created:** [September 10, 2024, 6:10pm UTC](https://discourse.julialang.org/t/need-advice-on-pecuzal-embedding-and-recurrencematrix/119257 "2024-09-10T18:10:22Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![NumberCruncher](https://avatars.discourse-cdn.com/v4/letter/n/9f8e36/32.png) [@NumberCruncher](https://discourse.julialang.org/u/NumberCruncher)
#### Post date: [September 10, 2024, 6:10pm UTC](https://discourse.julialang.org/t/need-advice-on-pecuzal-embedding-and-recurrencematrix/119257/1 "2024-09-10T18:10:22Z")

</div>

I’m new to Julia and looking to use it to analyse time-series.

My current aim is to compare MatrixProfile to RecurrenceMatrix for my application.

The trouble is that with the code below, I am encountering:

> ERROR: Computed 0-distances, due to duplicate datapoints in your data. Try to add minimal additive noise to the signal you wish to embed and try again.

My “solution” to that is to use `unique()` in `pecuzal_embedding` like so:

`Y, τ_vals, ts_vals, Ls, εs = pecuzal_embedding(unique(s),w=theiler)`

But it doesn’t smell right to me. So what’s the right thing to do ?

```julia
using Pkg
Pkg.add("Plots")
Pkg.add("DelayEmbeddings")
Pkg.add("MatrixProfile")
Pkg.add("CSV")
Pkg.add("DataFrames")
Pkg.add("RecurrenceAnalysis")
using Plots
using DelayEmbeddings
using MatrixProfile
using CSV
using DataFrames
using RecurrenceAnalysis

# Input data
csv = CSV.read("test.csv",DataFrame)

s = csv[:,2] 
theiler = estimate_delay(s, "mi_min") 
Y, τ_vals, ts_vals, Ls, εs = pecuzal_embedding(s,w=theiler)

println("Ls = ", Ls)
println("τ_vals = ", τ_vals)
println("L_total_uni: $(sum(Ls))")

# Calc
R=RecurrenceMatrix(Y,0.5)
recurrenceplot(R; ascii = true)
# RQA Measures
r=rqa(R,theiler=theiler)
for (key, value) in r
    println(string(key, " ", value))
end

```

---

<div class="post-metadata">

### Author: ![Datseris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/datseris/32/13406_2.png) [@Datseris](https://discourse.julialang.org/u/Datseris)
#### Post date: [September 10, 2024, 7:55pm UTC](https://discourse.julialang.org/t/need-advice-on-pecuzal-embedding-and-recurrencematrix/119257/2 "2024-09-10T19:55:15Z")

</div>

Try to add minimal additive noise to the signal you wish to embed and try again.

CU!

George
