Skip to content

Fix inverted TRRANDOM type codes for gaussian and exponential random sources - #410

Open
umutKaracelebi wants to merge 1 commit into
PySpice-org:masterfrom
umutKaracelebi:fix-random-source-type-codes
Open

umutKaracelebi wants to merge 1 commit into
PySpice-org:masterfrom
umutKaracelebi:fix-random-source-type-codes

Conversation

@umutKaracelebi

Copy link
Copy Markdown

RandomMixin.format_spice_parameters mapped random_type='gaussian' to ngspice
TRRANDOM type 3 and 'exponential' to type 2, but ngspice defines type 2 as
gaussian and type 3 as exponential (see the class docstring and ngspice's
Monte_Carlo example trrandom(2 ...) ; Gauss). A source declared gaussian
therefore produced strictly-positive exponential variates, and vice versa.

This swaps the two codes so the emitted netlist matches the documented mapping.

Test: pytest unit-test -> 29 passed, 2 skipped. The added
test_random_source_type_codes checks all four types and fails before the change.

Fixes #363.

…sources

RandomMixin.format_spice_parameters mapped 'exponential' to TRRANDOM type 2
and 'gaussian' to type 3, but ngspice defines type 2 as gaussian and type 3 as
exponential (as documented in the class docstring). A RandomVoltageSource /
RandomCurrentSource declared as 'gaussian' therefore emitted exponential
strictly-positive variates, and vice versa.

Swap the two codes and add a regression test covering all four random types.
Copilot AI balanced review requested due to automatic review settings November 29, 2026 23:23

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gaussian and Exponential numerical codes are inverted for random source simulation

2 participants