Talk:Linear congruential generator: Difference between revisions

 
(4 intermediate revisions by 3 users not shown)
Line 41:
{{alertbox|#ffffd8|These generators can yield negative numbers because the modulus operator of F# matches the sign of the first operand. The generators must only yield numbers from 0 to m - 1.
----
Negative numbers from lcg.bsd are <s>congruential</s> congruent to the correct numbers: -740551042 is <s>congruential</s> congruent to 1406932606. Negative numbers from lcg.ms are off by one, because the division truncated to the wrong direction: -11529 is <s>congruential</s> congruent to 21239, but expected 21238.}}
 
I know of 2 workarounds: (1) use [[bitwise operations]] to clear the sign bit, or (2) check if <code>formula (mod) m</code> is negative, and if so, add <code>m</code>. We might want to clarify the task. --[[User:Kernigh|Kernigh]] 17:21, 1 August 2011 (UTC)
 
:And some languages have the denominator for the first operand, instead of the numerator. But I believe your objection is against languages where modulus takes on the sign of the numerator rather than that of the denominator. --[[User:Rdm|Rdm]] 19:52, 1 August 2011 (UTC)
 
== Should the vectorized variant of the X86 Assembly LCG be included? ==
 
I recently read the instructions on this page more thoroughly. I initially believed that it was only necessary to create an LCG, not to replicate an existing implementation. The example posted under "Second example using AVX instructions." does not produce identical output to the Microsoft rand(). Should this example be removed completely? For now, I will add a comment to the vectorized implementation explaining that its output will differ from Microsoft rand(). [[User:Emjay|Emjay]] ([[User talk:Emjay|talk]]) 21:38, 22 August 2015 (UTC)
 
: I would mark it as incorrect, maybe someone can fix it. --[[User:Rdm|Rdm]] ([[User talk:Rdm|talk]]) 00:22, 23 August 2015 (UTC)
 
:: I did what you suggested, and am curious to see what the solution might be, as my understanding of mathematics is very limited. Thank you for the input, please feel free to offer any other suggestions; I am new to this site, and wiki editing in general. [[User:Emjay|Emjay]] ([[User talk:Emjay|talk]]) 18:27, 23 August 2015 (UTC)
Anonymous user