The Designer's Guide Community Forum
https://designers-guide.org/forum/YaBB.pl
Simulators >> Circuit Simulators >> How to vary a design variable in normal distribution form in ocean script?
https://designers-guide.org/forum/YaBB.pl?num=1392730098

Message started by indra0804 on Feb 18th, 2014, 5:28am

Title: How to vary a design variable in normal distribution form in ocean script?
Post by indra0804 on Feb 18th, 2014, 5:28am

Hi experts,

I want to vary a circuit design variable in the form of a normal distribution in ocean script ie. if for the 1st sim, the design variable 'cap' is 100fF, then may be in the 2nd sim, the value of 'cap' gets modified to say '100.5fF' or something like that as per normal distribution specs.

So, my question is, whether there is any function available in ocean for simulating normal distribution? I tried to find in the ocean reference manual, but couldn't find. Only thing that I could find is 'random' function which can generate random values in a certain range, but thats not quite the thing that I am looking for...Please help..!! And I don't want variation in a ordered manner, otherwise I could have used parametric analysis, but I want change in the form of some distribution.

Regards,

Indra

Title: Re: How to vary a design variable in normal distribution form in ocean script?
Post by boe on Feb 18th, 2014, 10:51am

Hi Indra,
does this thread help?
- B O E

Title: Re: How to vary a design variable in normal distribution form in ocean script?
Post by Andrew Beckett on Feb 18th, 2014, 4:17pm

Or if you really don't want to do it with Monte Carlo, maybe this code will help:


Code:
/* abRandomNormal.il

Author     A.D.Beckett
Group      Custom IC (UK), Cadence Design Systems Ltd.
Language   SKILL
Date        
Modified  
By        

Uses Box-Muller method to produce random numbers with
a normal distribution (mean 0, std dev 1).

Call abRandomNormal() multiple times to get such a sequence.

***************************************************

SCCS Info: @(#) abRandomNormal.il 11/30/12.14:22:28 1.1

*/

;------------------------------------------------------------------------
; Store math constants (such as PI) as properties on this symbol
;------------------------------------------------------------------------
(defMathConstants 'abRandomNormal)

/***************************************************************
*                                                              *
*                       (abRandomNormal)                       *
*                                                              *
*  Return a random number with normal distribution using the   *
*                      Box-Muller method                       *
*                                                              *
***************************************************************/
(defun abRandomNormal ()
 (let ((max (rightshift -1 1)) U V)
   (setq U (quotient (float (random max)) max))
   (setq V (quotient (float (random max)) max))
   ;--------------------------------------------------------------------
   ; could generate two independent numbers
   ; the other would use cos instead of sin
   ;--------------------------------------------------------------------
   (times (sqrt (times -2 (log U)))
          (cos (times 2 (getqq abRandomNormal PI) V)))
   )
 )

/***************************************************************
*                                                              *
*             (abTestRandomNormal numPoints bins)              *
*                                                              *
*   Function for testing - uses ViVA's plotting functions to   *
*  produce a histogram and also compute the mean and std dev   *
*      to ensure that with enough points it looks normal       *
*               (e.g numPoints 100000, bins 100)               *
*                                                              *
***************************************************************/

(defun abTestRandomNormal (numPoints bins)
 (let (x y wave)
   (setq x (drCreateVec 'intlong numPoints))
   (setq y (drCreateVec 'double numPoints))
   (for i 0 numPoints
        (drAddElem x i)
        (drAddElem y (abRandomNormal))
        )
   (setq wave (drCreateWaveform x y))
   (awvPlotWaveform (newWindow) (list (histo wave bins nil nil)))
   (printf "Mean=%g\nStd Dev=%g\n" (average wave) (stddev wave))
   )
 )

The Designer's Guide Community Forum » Powered by YaBB 2.2.2!
YaBB © 2000-2008. All Rights Reserved.