how to find derivative of an array of numbers - arrays

I need help in finding derivative of single array consisting on [1111222221111122222]
need how to get derivative of 1, -1 and 0 from above ? iam using numpy. i need some help in logic

I don't know the problem in detail, but maybe you can use numpy.diff or numpy.gradient.

Related

Is there a discrete dirac delta function in Julia?

The title sums it up. I have seen some mentions in the RatFun and SpectralMeasures package but I am mostly looking for a function analogous to the ones found in the Sympy module for Python.
Edit: Thanks everyone for your answers and comments. I was looking for the discrete version of a dirac delta. At first I was confused and wanted to look for a "function" but I actually was just looking for the Kronecker delta which exhibits the following behavior:
delta(x) = 1 if x=0
delta(x) = 0 otherwise
I quickly realized that I didn't even need a function, I just had to take care of the differences in the argument. Thanks again!
There is a Dirac type in MeasureTheory.jl, but unsure if it fits your needs.
The OP basically wants the Kronecker delta function
[https://en.wikipedia.org/wiki/Kronecker_delta]
which is trivial in julia:
delta(n) = n == 0

How to get interpolated value for 1D array in LabVIEW?

I have two 1D arrays that gives an array of points on the XY plane. What I am trying to achieve is to find that steps interpolation for which values is exactly 0.5. I've tried to solve it using Interpolate 1D array and Threshold 1D array but no success. The first only returns values information for which steps == 0.5 and the latter is not doing anything apparently, returning 0 always.
I've attached the front panel and block diagram to the post. On the front panel I indicated which information I need.
Could you please help me figure out what I am doing wrong here? Because I'm quite stuck with this. Thank you in advance.
Kudos for solving it yourself, but a vi post of the solution would be appreciated for further reference by other people. Here is a solution that uses the 1D interpolation from the mathematics section. One VI, only downside is that you need to convert you interpolation value to an array and the answer back.
I managed to solve it. Threshold 1D array vi cannot deal with arrays that contain decreasing values... a rather frustrating error, as I need to transform the array so that the characteristics become increasing to obtain the interpolated value.
From the documentation:
Note Use this function only with arrays sorted in non-descending
order.

Maxima: How to turn all coefficients of a polynomial positive

For a maths project I am currently using the CAS Maxima (wxMaxima). As the project is almost finished I would like to remain with Maxima, but there is one problem left:
The issue is that I have to convert a certain polynomial P by making all its coefficients positive. I.e. adding up the absolutes of all coefficients (but not taking the absolute value of the whole polynomial), for example
P(...)=-15x^3+3y^2-4x^2
turns to
P'(...)=15x^3+3y^2+4x^2
I could not find an implemented function that would help me with this. And could not find a solution by implementing it with a map function. Do you know a way to solve this issue?
Thank you for your help!
Jonas
You can calculate a sum of absolute values:
P:-15*x^3+3*y^2-4*x^2;
P2:sum(abs(args(P)[i]),i,1,length(args(P)));
>> 3*y^2+15*x^2*abs(x)+4*x^2
(unfortunately, here is abs(x) but you can use subst(x,abs(x),P2))
The same with map:
P2:map(abs,P);
Or convert an expresstion to string and replace "-" to "+":
s:string(P);
s2:ssubst("+","-",s);
P2:eval_string(s2);
>> 3*y^2+15*x^3+4*x^2

Find the inverse of a sequence in integers in Mathematica

Let k[i] is a strictly increasing data and
A=Table[k[i],{i,1,30}];
B=List[k[1],k[3],k[4],k[7],k[10],k[12],k[17],k[18],k[19],k[23],k[26]];
Now I would like to get what is the index for B[n], for example B[4]=A[7], and my question is to get 7. I tried InverseFunction,
InverseFunction[A][B[4]]
but it does not work. A similar question arise when I define A and B by the following sets
A=List[k[1],k[2],k[3],k[4],k[5],k[6],k[7],k[8],k[9],k[10],k[11],k[12],k[13],k[14],k[15]];
B=List[k[1],k[3],k[4],k[7],k[10],k[12],k[14]];
If the problem is in the method of representing data by the function List, please let me know a better way.

How does the bwarea function of matlab work and how can I implement it in C?

I want to understand the working of the bwarea function of MATLAB. Also I want to implement this function in C. Any idea about how to implement will be very helpful.
Also is there a substitute for bwarea in opencv?
Thanks.
The manual suggests to examine the pixels by 2-by-2 neighbours.
These neighbours can take 6 different patterns which I tried to picture here. Examining each and every 2-by-2 neighbour and calculating the total is how bwarea works.

Resources