Derivative for a set of ... points

Dear all,
I am successfully playing with

sol = solve(ensembleprob,SRIW1(),EnsembleThreads(),trajectories=ϕ,saveat=δt);

which generates a nice set of values. Among those values sol[1,:,:]; is a position, sol[2,:,:]; a velocity.
unfortunately, I need an acceleration…
how can I nicely proceed ?
thx !
Frédéric

auto-reply :slight_smile:
here is my idea :

kt = sol[9,:,16]

60001-element Array{Float64,1}:

with \delta t = 0.01 then

lmnt = length(kt)
kt_t = Vector{Float64}(undef,lmnt);
for i in 1:lmnt kt_t[i] = (i-1)*δt end;
@time kt_acc = ForwardDiff.gradient(kt, kt_t)

MethodError: objects of type Array{Float64,1} are not callable
Use square brackets for indexing an Array.

where am I wrong ??
Thx !
Frédéric

@Frederic_Gilt, you may want to take a look at this discourse thread.

thx for the link, but kt is solution of SDE (white noise forcing term) so I want to avoid interpolation then derivation.
I was hoping ForwardDiff to be able to help me on this

(re)auto-reply
kt is not a function (callable I guess ?) so not suitable for ForwardDiff… my bad ! :thinking:

now shifting to FiniteDifferences package… but once again exemples are for functions (!) :face_with_raised_eyebrow:
anyone with a simple exemple of FiniteDifferences use with data only (data = kt, time = kt_t)
Thx a lot !

sadly ended with a five-point stencil scheme :

for i in 3:(lmnt-2) 
    kt_a[i] = (-kt[i+2]+8*kt[i+1]-8*kt[i-1]+kt[i-2])/(12*δt)
end;

:roll_eyes: