Version 4 SHEET 1 880 680 WIRE 192 64 128 64 WIRE 272 64 192 64 WIRE 432 64 352 64 WIRE 512 64 432 64 WIRE 576 64 512 64 WIRE 128 96 128 64 WIRE 432 112 432 64 WIRE 128 208 128 176 WIRE 432 208 432 176 FLAG 128 208 0 FLAG 192 64 NOISE FLAG 432 208 0 FLAG 512 64 LPF SYMBOL bv 128 80 R0 WINDOW 0 -68 104 Left 2 WINDOW 3 -225 179 Left 2 SYMATTR InstName B1 SYMATTR Value V=58.65 * ( rand(12345*time) - 0.5 ) SYMBOL res 368 48 R90 WINDOW 0 72 56 VBottom 2 WINDOW 3 78 56 VTop 2 SYMATTR InstName R1 SYMATTR Value 1 SYMBOL cap 416 112 R0 WINDOW 0 70 20 Left 2 WINDOW 3 63 53 Left 2 SYMATTR InstName C1 SYMATTR Value 0.016 TEXT -176 104 Left 2 !.tran 0 10 0 10u TEXT 24 -40 Left 2 ;10 Hz Noise Source J Larkin July 28, 2014
rand() runs about 6 times faster than random() and gives slightly better crest factors and a mildly messier spectrum. Shaping the noise spectrum would be easy by futzing the filter.
--
John Larkin Highland Technology, Inc
jlarkin att highlandtechnology dott com
http://www.highlandtechnology.com
The weird artifacts come from excess Mike cleverness, and from not setting a maximum time step. Try this, switch to straight trapezoidal and the "alternate" solver, and use a 2097152-point FFT. Good behaviour results.
Cheers
Phil Hobbs
Version 4 SHEET 1 1656 900 WIRE -480 208 -512 208 WIRE -480 224 -480 208 WIRE -1040 240 -1056 240 WIRE -800 240 -816 240 WIRE -1056 288 -1056 240 WIRE -816 288 -816 240 WIRE 128 288 0 288 WIRE 144 288 128 288 WIRE 0 320 0 288 WIRE -480 336 -480 304 WIRE -160 336 -176 336 WIRE -48 336 -160 336 WIRE -160 384 -176 384 WIRE -48 384 -160 384 WIRE -1056 400 -1056 368 WIRE -816 400 -816 368 WIRE -496 416 -512 416 WIRE -496 432 -496 416 WIRE 0 432 0 400 WIRE -496 528 -496 512 FLAG -1056 400 0 FLAG -1040 240 n1 FLAG -816 400 0 FLAG -800 240 n2 FLAG -496 528 0 FLAG -480 336 0 FLAG -512 416 gn1 FLAG -512 208 gn2 FLAG 0 432 0 FLAG -160 336 gn2 FLAG -160 384 gn1 FLAG 128 288 out SYMBOL bv -1056 272 R0 SYMATTR InstName B2 SYMATTR Value V=random(50000*time) SYMBOL bv -816 272 R0 SYMATTR InstName B1 SYMATTR Value V=rand(101000*time+21000) SYMBOL bv -496 416 R0 SYMATTR InstName B3 SYMATTR Value V=sqrt(-2*ln(v(n2)))*cos(2*pi*v(n1)) SYMBOL bv -480 208 R0 WINDOW 3 60 49 Left 2 SYMATTR Value V=sqrt(-2*ln(v(n2)))*sin(2*pi*v(n1)) SYMATTR InstName B4 SYMBOL e 0 304 R0 SYMATTR InstName E1 SYMATTR Value {1/sqrt(2)} TEXT -1048 456 Left 2 !.tran 0 2.097152 0 1u TEXT -1256 496 Left 2 ;ARRRGGG! can't run for more than 8mS, else nulls out!!\ngn1,2's PDF appears to 'peak' somewhere near -0.12 in the range
TEXT -408 448 Left 2 !.options plotwinsize=0
Version 4 SHEET 1 1656 900 WIRE -480 208 -512 208 WIRE -480 224 -480 208 WIRE -1040 240 -1056 240 WIRE -800 240 -816 240 WIRE -1056 288 -1056 240 WIRE -816 288 -816 240 WIRE 128 288 0 288 WIRE 144 288 128 288 WIRE 0 320 0 288 WIRE -480 336 -480 304 WIRE -160 336 -176 336 WIRE -48 336 -160 336 WIRE -160 384 -176 384 WIRE -48 384 -160 384 WIRE -1056 400 -1056 368 WIRE -816 400 -816 368 WIRE -496 416 -512 416 WIRE -496 432 -496 416 WIRE 0 432 0 400 WIRE -496 528 -496 512 FLAG -1056 400 0 FLAG -1040 240 n1 FLAG -816 400 0 FLAG -800 240 n2 FLAG -496 528 0 FLAG -480 336 0 FLAG -512 416 gn1 FLAG -512 208 gn2 FLAG 0 432 0 FLAG -160 336 gn2 FLAG -160 384 gn1 FLAG 128 288 out SYMBOL bv -1056 272 R0 SYMATTR InstName B2 SYMATTR Value V=random(50000*time) SYMBOL bv -816 272 R0 SYMATTR InstName B1 SYMATTR Value V=rand(101000*time+21000) SYMBOL bv -496 416 R0 SYMATTR InstName B3 SYMATTR Value V=sqrt(-2*ln(v(n2)))*cos(2*pi*v(n1)) SYMBOL bv -480 208 R0 WINDOW 3 60 49 Left 2 SYMATTR Value V=sqrt(-2*ln(v(n2)))*sin(2*pi*v(n1)) SYMATTR InstName B4 SYMBOL e 0 304 R0 SYMATTR InstName E1 SYMATTR Value {1/sqrt(2)} TEXT -1048 456 Left 2 !.tran 0 2.097152 0 1u TEXT -1256 496 Left 2 ;ARRRGGG! can't run for more than 8mS, else nulls out!!\ngn1,2's PDF appears to 'peak' somewhere near -0.12 in the range
TEXT -408 448 Left 2 !.options plotwinsize=0
--
Dr Philip C D Hobbs
Principal Consultant
ElectroOptical Innovations LLC
Optics, Electro-optics, Photonics, Analog Electronics
160 North State Road #203
Briarcliff Manor NY 10510
hobbs at electrooptical dot net
http://electrooptical.net
That method is appealingly simple, I agree. It generates independent samples much more slowly than the Box-Mueller approach, though, because you're relying on the central limit theorem to give you your Gaussian statistics, rather than applying the inverse function.
Cheers
Phil Hobbs
--
Dr Philip C D Hobbs
Principal Consultant
ElectroOptical Innovations LLC
Optics, Electro-optics, Photonics, Analog Electronics
160 North State Road #203
Briarcliff Manor NY 10510
hobbs at electrooptical dot net
http://electrooptical.net
Eternal September costs the same as aioe, and doesn't have the silly limitation.
Cheers
Phil Hobbs
--
Dr Philip C D Hobbs
Principal Consultant
ElectroOptical Innovations LLC
Optics, Electro-optics, Photonics, Analog Electronics
160 North State Road #203
Briarcliff Manor NY 10510
hobbs at electrooptical dot net
http://electrooptical.net
Acutally white() is not a bad basis, but was 'difficult' to concquer the myriad of problems, thus the solution I posted to you.
This is your second email ADMITTING to not providing your offer of two noise sources. The other one you talked about 100 and 101 as some point of a flaw and this one you call it a basis. Still interested in a simple two resistor circuit with two sources
I'll post one here for you later, It has an interesting way to show the effects of that rounding in LTspice.
On Tue, 29 Jul 2014 07:26:15 -0700, John Larkin wrote:
No, they are not independent.
Again, Vrms for N1, N2, and sum are approximately the same value.
Check the spectrum of N1, N2 [which are the same], BUT the spectrum for the sum is off more than 8dB, signifying a fair bit of 'non-independency'.
you did look at my other reply?
named NoiseSources_JohnLarking_compared.asc
Version 4 SHEET 1 2088 680 WIRE -176 -256 -240 -256 WIRE -112 -256 -176 -256 WIRE -48 -256 -112 -256 WIRE 528 -256 464 -256 WIRE 592 -256 528 -256 WIRE 656 -256 592 -256 WIRE -240 -224 -240 -256 WIRE 464 -224 464 -256 WIRE -240 -112 -240 -144 WIRE 464 -112 464 -144 WIRE 160 -80 64 -80 WIRE 192 -80 160 -80 WIRE 864 -80 768 -80 WIRE 896 -80 864 -80 WIRE 64 -64 64 -80 WIRE 768 -64 768 -80 WIRE -176 -48 -176 -256 WIRE 16 -48 -176 -48 WIRE 528 -48 528 -256 WIRE 720 -48 528 -48 WIRE 16 0 -176 0 WIRE 720 0 528 0 WIRE 64 64 64 16 WIRE 768 64 768 16 WIRE -176 128 -176 0 WIRE -176 128 -240 128 WIRE -112 128 -176 128 WIRE -48 128 -112 128 WIRE 528 128 528 0 WIRE 528 128 464 128 WIRE 592 128 528 128 WIRE 656 128 592 128 WIRE -240 160 -240 128 WIRE 464 160 464 128 WIRE -240 272 -240 240 WIRE 464 272 464 240 FLAG -240 272 0 FLAG -112 128 uniform_N2 FLAG -240 -112 0 FLAG -112 -256 uniform_N1 FLAG 64 64 0 FLAG 160 -80 uniform_out FLAG 464 272 0 FLAG 592 128 white_N2 FLAG 464 -112 0 FLAG 592 -256 white_N1 FLAG 768 64 0 FLAG 864 -80 white_out SYMBOL bv -240 144 R0 WINDOW 0 97 46 Left 2 WINDOW 3 51 95 Left 2 SYMATTR InstName B1 SYMATTR Value V= 3.94 * ( random(100*time) - 0.5 ) SYMBOL bv -240 -240 R0 WINDOW 0 84 55 Left 2 WINDOW 3 50 100 Left 2 SYMATTR InstName B2 SYMATTR Value V= 3.94 * ( random(1021*time) - 0.5 ) SYMBOL e 64 -80 R0 SYMATTR InstName E1 SYMATTR Value {1/sqrt(2)} SYMBOL bv 464 144 R0 WINDOW 0 97 46 Left 2 WINDOW 3 51 95 Left 2 SYMATTR InstName B3 SYMATTR Value V= 4.08*white(100*time) SYMBOL bv 464 -240 R0 WINDOW 0 84 55 Left 2 WINDOW 3 50 100 Left 2 SYMATTR InstName B4 SYMATTR Value V= 4.08*white(1021*time) SYMBOL e 768 -80 R0 SYMATTR InstName E2 SYMATTR Value {1/sqrt(2)} TEXT 176 -304 Left 2 !.tran 0 10 0 100u TEXT -112 -352 Left 2 ;MODIFIED [Some time-domain noise sources J Larkin July 26, 2014] TEXT 1040 -112 Left 2 ;NOTE: useable range is only minimum to 25Hz due to the use of 100 as a k factor\nvery slow analysis for only two sets of sources,shudder at 10 of these!\nwhy are the 'independent' noise sources produce 8 dB more energy?\nhow does anyone interpret the nV/rtHz from the the spectral plot? TEXT 920 96 Left 2 ;white() is described as a 'gaussian' distribution value limited random signal\nrandom() is described as a 'uniform' distribution also value limited random signal\nIt is very interesting the spectrum of the two so closely match and \n further the distributions do not seem to impact that spectrum TEXT 896 -264 Left 2 ;ERROR: the rms voltage of EACH noise is 1 Vrms, \nyet over the 'useable' range of 0.1Hz to 25 Hz\nthe spectral energies are NOT the same and are off by over 8dB
I measured the sum as almost exactly 1.41 times the individual values. N1 and N2 only correlate for the first second, and that was deliberate. You don't have to do that.
You can break almost anything that you don't like. LT Spice will help you if you want.
--
John Larkin Highland Technology, Inc
jlarkin att highlandtechnology dott com
http://www.highlandtechnology.com
On Mon, 28 Jul 2014 21:00:57 -0700, John Larkin wrote:
As promised here is a simple resistor network with CALIBRATED noise sources. The schematic has comparison notes. It is interesting to note that the resistor networks do NOT even add a single node to the PSpice solution matrix, which maintains speed [and I'll bet accuracy]
some of the fonts may not transfer.
ResistorCompare.asc
Version 4 SHEET 1 27404 712 WIRE 896 -16 880 -16 WIRE 1344 -16 896 -16 WIRE 1936 -16 1424 -16 WIRE 2048 -16 1936 -16 WIRE 2112 -16 2048 -16 WIRE 2208 -16 2112 -16 WIRE 880 16 880 -16 WIRE 1936 16 1936 -16 WIRE 2048 32 2048 -16 WIRE 2144 32 2048 32 WIRE 2048 112 2048 96 WIRE 2144 112 2048 112 WIRE 2368 112 2256 112 WIRE 2416 112 2368 112 WIRE 880 144 880 96 WIRE 1936 144 1936 96 WIRE 2048 144 2048 112 WIRE 2256 160 2256 112 WIRE 2208 176 2208 -16 WIRE 2256 272 2256 240 WIRE 1248 320 1232 320 WIRE 1312 320 1248 320 WIRE 1328 320 1312 320 WIRE 1424 320 1408 320 WIRE 1936 320 1424 320 WIRE 2048 320 1936 320 WIRE 2112 320 2048 320 WIRE 2208 320 2208 224 WIRE 2208 320 2112 320 WIRE 1936 336 1936 320 WIRE 1936 336 1856 336 WIRE 1856 352 1856 336 WIRE 1936 352 1936 336 WIRE 2048 368 2048 320 WIRE 2144 368 2048 368 WIRE 1312 400 1312 320 WIRE 1328 400 1312 400 WIRE 1424 400 1424 320 WIRE 1424 400 1408 400 WIRE 1856 448 1856 432 WIRE 1936 448 1936 432 WIRE 1936 448 1856 448 WIRE 2048 448 2048 432 WIRE 2144 448 2048 448 WIRE 1936 480 1936 448 WIRE 2048 480 2048 448 FLAG 880 144 0 FLAG 1936 144 0 FLAG 2048 144 0 FLAG 1936 480 0 FLAG 2048 480 0 FLAG 896 -16 in FLAG 1248 320 in FLAG 2112 320 out FLAG 2112 -16 out1 FLAG 2256 272 0 FLAG 2368 112 compare SYMBOL res 1328 0 R270 WINDOW 0 32 56 VTop 2 WINDOW 3 0 56 VBottom 2 SYMATTR InstName Rs1 SYMATTR Value {Rs} SYMBOL res 1920 0 R0 SYMATTR InstName Rload1 SYMATTR Value {Rload} SYMBOL voltage 880 0 R0 WINDOW 0 -119 20 Left 2 WINDOW 3 -249 101 Left 2 WINDOW 123 -131 67 Left 2 WINDOW 39 0 0 Left 2 SYMATTR InstName Vin SYMATTR Value SINE(0 100uV 100kHz) SYMATTR Value2 AC 1 SYMBOL cap 2032 32 R0 SYMATTR InstName Cload1 SYMATTR Value 1nF SYMBOL res 1312 336 R270 WINDOW 0 32 56 VTop 2 WINDOW 3 -1 62 VBottom 2 SYMATTR InstName Rs2 SYMATTR Value {Rs} SYMBOL res 1920 336 R0 SYMATTR InstName Rload2 SYMATTR Value {Rload} SYMBOL cap 2032 368 R0 SYMATTR InstName Cload2 SYMATTR Value 1nF SYMBOL e 2256 144 R0 SYMATTR InstName Ecompare SYMATTR Value 1 SYMBOL current 1328 400 R270 WINDOW 0 -66 33 VTop 2 WINDOW 3 -94 33 VTop 2 SYMATTR InstName InoiseRs SYMATTR Value PWL value_scale_factor={sqrt(4*k*T/Rs*fmax)} time_scale_factor={dt} file=Vn1.txt SYMBOL current 1856 352 R0 WINDOW 0 -142 -7 Left 2 WINDOW 3 -154 176 Left 2 SYMATTR InstName InoiseRload SYMATTR Value PWL value_scale_factor={sqrt(4*k*T/Rload*fmax)} time_scale_factor={dt} file=Vn2.txt TEXT 584 424 Left 2 !.tran 0 {Tstop} {Tstart} {dt/2} TEXT 592 344 Left 2 ;.ac dec 100 {BW} {fmax} TEXT 592 376 Left 2 ;.noise V(out) Vin dec 100 {BW} {fmax} TEXT 1400 -104 Left 2 ;NORMAL CIRCUIT TEXT 1376 232 Left 2 ;.TRANOISE CIRCUIT TEXT 584 168 Left 2 !.options plotwinsize=0\n.param Rs=1k Rload=5k\n.param k=1.38e-23 T=300 N=20000 fmax=10MEG\n.param Tstop={1.1*N/2/fmax} Tstart={0.1*N/2/fmax}\n.param dt={1/2/fmax} BW={2*fmax/N} TEXT 1256 104 Left 2 ;Circuit set up for 1kHz to 10MHz operation TEXT 2472 -16 Left 2 ;.ac V(out) at 100kHz is -2.62657dB, if rms for
100uVp signal that is 52.258 uVrms\n.noise V(onoise) shows
at 3.2 nV/rtHz\n with no cap, approx -140dBV, estimate
3.2 nVrms/rtHz\n using V(out), peak arppox -86.0377dBV\n octave Post Processing:\n using V(compare_eq)\n time waveform, 2.04uVrms\n after conversion to spectrum using time2freq, starts with 3.64nV/rtHz\n using V(out_eq)\n after conversion to spectrum using time2freq, peak occurs at -85.639 dBV,
52.246uVrms TEXT 824 520 Left 2 ;NOTE: Usually the full formula of each PWL description are NOT shown,\n but are left shown here for review.
Barfs repeatedly for syntax errors. Probably you need to post with wrap turned off.
Also LTspice doesn't like "time_scale_factor={dt}" ...Jim Thompson
--
| James E.Thompson | mens |
| Analog Innovations | et |
| Analog/Mixed-Signal ASIC's and Discrete Systems | manus |
| San Tan Valley, AZ 85142 Skype: skypeanalog | |
| Voice:(480)460-2350 Fax: Available upon request | Brass Rat |
| E-mail Icon at http://www.analog-innovations.com | 1962 |
I love to cook with wine. Sometimes I even put it in the food.
Sure, but not by that large a factor, I shouldn't think. Modelling the edges of the distribution accurately out so some crest factor M requires integrating uniformly-distributed noise for some really long time (something like exp(M**2/2) samples), whereas with the Box-Mueller method, you get the Gaussian distribution to machine precision (or whatever your random generator can do) in one step.
Of course in LTspice, the rounded edges happen before the Box-Mueller transform, which will mess up the distribution a bit. One should really sample in the middle of the interval, transform, and then smooth again.
Whether any of that is worth the trouble depends on the situation. Shot noise and Johnson noise are really really Gaussian, so if one were trying to model the counting statistics of threshold crossings, for instance, you'd care quite a lot.
Cheers
Phil Hobbs
--
Dr Philip C D Hobbs
Principal Consultant
ElectroOptical Innovations LLC
Optics, Electro-optics, Photonics, Analog Electronics
160 North State Road #203
Briarcliff Manor NY 10510
hobbs at electrooptical dot net
http://electrooptical.net
The alternative would be to sum a few (3-10 maybe) rand(K*time) terms and lowpass filter just enough to tame the edges. Crest factor would be OK for most uses... grows by square root of the number of summed sources, I think. I don't know if that would be faster or slower than Box-Mueller, and there's no way to tell but to try it.
I was impressed by random() being 6:1 slower than rand().
This discussion is interesting. I have no use for it right now, but I'm fairly sure I will one of these days. It is a break from writing Python test scripts.
I wonder if LT Spice pre-compiles or interprets math expressions. That could probably be determined by experiment.
--
John Larkin Highland Technology, Inc
jlarkin att highlandtechnology dott com
http://www.highlandtechnology.com
ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here.
All logos and trade names are the property of their respective owners.