I've had a few instances where I was interested in seeing the probability density function of a waveform, the voltage histogram, in LT Spice. I never came up with a decent way to display that within Spice. Any ideas?
PDF in Spice
You could make a subcircuit with a bunch of switches, capacitors, and current sources, which would integrate the amount of time the voltage spent between thresholds N and N+1.
It would get a bit clunky if you wanted more than about a dozen levels, of course.
Cheers
Phil Hobbs
Yeah, brute force. A quantizer and a decoder could fake a mess of window comparators, and integrators are easy, but a nice histogram display is messy.
I have done a single swept window comparator that scans the test waveform, but run times get insane.
I guess the thing to do is export the waveform to a file and analyze it with some other software. Seems inelegant.
Transient analysis in Spice has no noise. ...Jim Thompson
Not as inelegant as having MANY advantages.
You know this sequence, but here it is for 'lurkers':
In LTspice, set .options plotwinsize=0 to catch ALL the waveform
use LTsputil.exe to make all the samples uniformly spaced, I use a batch file to expedite.
Export the resulting evenly spaced trace to text file and edit that file by removing the 'header' and the first t=0 term, rename as something REALLY simple.
Then in octave
from there you can plot ANY number of bins in the histogram.
Sometimes it's worthwhile to explore different numbers of bins and this makes it super easy.
I sometimes 'overlay' the plots with larger and larger number of bins just looking for characteristics. Any bin that might have a 'bump' really shows up that way.
.tranoise does, but I'm usually working with white noise, sometimes 1/f but neither affect pdf ?!
I was going to mention your method, but figured you'd be right here shortly ;-) ...Jim Thompson
That's OK, I'm building a noise generator! I want to see how Gaussian it might be, as I tweak things.
Yup. And noise analysis has no transients! What I really want is a negative resistor with pure imaginary noise.
Cheers
Phil Hobbs
Histogramming shouldn't care about even spacing.
Sure, but that hardly provides timely feedback.
OK. I don't know if it exists in LTspice, but I'd look for an LTspice equivalent to PSpice's "Performance Analysis". ...Jim Thompson
The noise isn't imaginary, it's just inverted.
In the Biblical sense ?>:-} ...Jim Thompson
sqrt(-4kTR) !
Cheers
Phil Hobbs
You can easily make a 2-terminal negative resistor; I made one as a college EE project. It's fun to plug -R into all the usual circuit equations.
But the noise will be real!
True, but part of making 'histogramming' not care about spacing is to evenly space the data points, else many programs 'double' count.
Using that method enabled me to make LTspice create a multitude of independent gaussian white noise sources. And I mean FLAT white noise.
Example of one: sqrt(12/5/dt)*(rand(time/dt)
+rand(tstop/dt+1+2*int(time/dt)) +rand(3*(tstop/dt+1)+3*int(time/dt)) +rand(6*(tstop/dt+1)+4*int(time/dt)) +rand(10*(tstop/dt+1)+5*int(time/dt))-2.5) }which only requires 5 rand() functions, normalized, and fairly close approx to gaussian pdf while remaining VERY spectrally flat.
The 'list' keeps going so I have up to 50 independant gaussian white noise sources to use. Just as long as the argument of rand() does NOT exceed
2^30, the sequences do not repeat.Join the Discussion
Have something to add? Share your thoughts — no account required.
Didn't find your answer?
Ask the community — no account required