Continue to Site

# [SOLVED]Can't find summation function in ADE calculator

Status
Not open for further replies.

#### dirac16

##### Member level 5
I want to do a linear regression analysis on an output signal of a transient analysis. Particularly, I am interested in the slope of the line and not the offset. The formula below indicates the equation for the slope:
The n is the size of the x and y vector. I have tried to implement this by ADE calculator. I have the data for x and y but the thing is I can't find a function for summation in the functions list. Is there any way that you know to calculate the slope in ADE?

#### Dominik Przyborowski

Integral is an infinite sum of infinitesimal elements.
Use integ or iinteg function

#### dirac16

##### Member level 5
The problem with integ function is that you need to specify both start and stop values for the definite integration. We do not know in advance what start and stop are for each of individual sums in the slope equation. That is why I am thinking of a discrete summation over the elements of a row vector.

#### Dominik Przyborowski

I believe xi and yi are a scalar values obtained from a waveform. Are they unique for given simulation run (corner, sweep)? Or, are they unique for cycle in single simulation run?
There are also statistical functions in ViVA which might be used. With more details, it might be possible to find tidy solution.

#### dirac16

##### Member level 5
Yes right. I have a time difference amplifier which amplifies the difference between two signals, namely Start and Stop. The input-output characteristic of the amplifier is T=A(Stop-Start), where A is the gain of the amp, Stop-Start (or x in the above formula) is the time difference to be amplified, and T (or y in the formula above) is the amplified time. The time difference increments from 0ps all the way to 449ps through 1ps time steps. So the length of the x and y vectors are each 450, but the actual range of the yi axis is not fixed due to PVT variations and also the non-linear behavior of the amplifier. By linear regression analysis I'd hopefully be able to report the average gain for my amplifier.

#### Dominik Przyborowski

So, what do you want to achieve is to make a best fit line across meausered 450 points, right?
On cadence support should be available skill function for this (I believe it's named abBestFit or sthing like this).

If you have not an access to support site, then calculate determination coefficient (slope of line) by using average and stdev functions.

#### wwfeldman

sumxy = 0
sumx = 0
sumx2 = 0
sumy = 0

for i = 1 to n
sumxy = sumxy + xi * yi
sumx = sumx + xi
sum2 = sumx2 = (xi * xi)
sumy = sumy + yi
end for loop

slopenumerator = (n*sumxy) - (sumx*sumy )
slopedenominator = (n*sumx2)-(sumx*sumx)

slope = slopenumerator/slopedenominator

#### dirac16

##### Member level 5
sumxy = 0
sumx = 0
sumx2 = 0
sumy = 0

for i = 1 to n
sumxy = sumxy + xi * yi
sumx = sumx + xi
sum2 = sumx2 = (xi * xi)
sumy = sumy + yi
end for loop

slopenumerator = (n*sumxy) - (sumx*sumy )
slopedenominator = (n*sumx2)-(sumx*sumx)

slope = slopenumerator/slopedenominator
Great, but how can I send this script to ADE outputs? I am doing Monte Carlo analysis where I need to run this script for many runs. So it would be best if I can send this expression to ADE in some way?

#### Dominik Przyborowski

Use average function
$average(x_i) = \frac{ \sum x_i } {n}$

#### dirac16

##### Member level 5
Use average function
$average(x_i) = \frac{ \sum x_i } {n}$
Alright, sounds good. With that method I try to find the average gain and through many runs of Monte Carlo (for process and mismatch) I would get a histogram of the average gain with a std value. Right?
--- Updated ---

The only problem I notice from average gain approach is it is perhaps not capable of minimizing gain error through least squares method as is done by linear regression analysis. I mean the average gain may not be the optimum gain for which the gain error is minimized. That is the only concern with your approach. I don't know if that makes a nicety at all with the output provided by slope function.

Last edited:

#### Dominik Przyborowski

Use average function to calculate all estimates and slope.
Follow definition of the average function (you can find it in ViVA user guide) and stdev as well, and use linear regression formulas.

#### dirac16

##### Member level 5
Use average function to calculate all estimates and slope.
Follow definition of the average function (you can find it in ViVA user guide) and stdev as well, and use linear regression formulas.
Thank you. I was finally able to use integ function as you suggested with a bit more effort. The problem is solved now.

Status
Not open for further replies.