2
$\begingroup$

I am normally not working with Mathematica, but I have to understand a code written in i!

Can some body say what the arguments and parameters of code below say?

RandomReal[NormalDistribution[mz, (mz - sz)/1.64485], nd]
$\endgroup$
7
  • 3
    $\begingroup$ Not sure that should work...? It looks like it should be RandomVariate. In the future, look this up in the docs, e.g. by looking up the docs for NormalDistribution, but RandomVariate[NormalDistribution[mz, (mz - sz)/1.64485], nd] would mean you'd take nd samples from the normal distribution centered at mz with std. dev. (mz - sz)/1.64485. $\endgroup$
    – b3m2a1
    Commented Apr 12, 2019 at 8:28
  • $\begingroup$ Thanks @b3m2a1 Actually after 'nd' there is one more parameter as 'mz'. but it is editted and deleted:). but what you explained is very clear. Thanks! $\endgroup$
    – Seda
    Commented Apr 12, 2019 at 9:24
  • $\begingroup$ Yeah I deleted that because it wasn't valid syntax and thus meant nothing without some enclosing context. If you would like it back you can re-edit it, but if you do you'll be missing something wrapping RandomReal. $\endgroup$
    – b3m2a1
    Commented Apr 12, 2019 at 9:25
  • $\begingroup$ Oh, ok! may be the code is incorrect I ll check it $\endgroup$
    – Seda
    Commented Apr 12, 2019 at 9:27
  • 5
    $\begingroup$ @b3m2a1 RandomReal was the original way to do this, and it still works in version 10.1 at least. $\endgroup$
    – Mr.Wizard
    Commented Apr 12, 2019 at 9:55

1 Answer 1

8
$\begingroup$

Szabolcs encouraged me to post this as an answer. The use of RandomReal and RandomInteger with statistical distributions was introduced, I believe, in version 6, prior to the introduction of RandomVariate in version 8. This can be seen by looking at the Mathematica legacy documentation, specifically version 6 tutorials:

  • Random Number Generation

    The functions RandomReal, RandomInteger, and RandomComplex generate uniformly distributed random numbers. RandomReal and RandomInteger also generate numbers for built-in distributions.

  • Continuous Distributions

    RandomReal[dist] gives pseudorandom numbers from the specified distribution.

    RandomReal[dist, dims] pseudorandom array with dimensionality dims, and elements from the specified distribution

  • Discrete Distributions

    RandomInteger[dist] pseudorandom number with specified distribution

    RandomInteger[dist, dims] pseudorandom array with dimensionality dims, and elements from the specified distribution

Although this syntax is now deprecated in favor of the unifying RandomVariate it nevertheless remains valid, confirmed through the current version 12.0.


To answer the question actually asked, consult the documentation for NormalDistribution

NormalDistribution[μ, σ]

represents a normal (Gaussian) distribution with mean μ and standard deviation σ.

So your code requests nd samples of a normal distrubiton with a mean mz and a SD of (mz - sz)/1.64485.

$\endgroup$
1
  • 1
    $\begingroup$ Thanks a lot. it is a very useful info for me because the programmer wants to update the version for the program that he wrote. the parameters of distribution that I asked are also clear. Thanks!! $\endgroup$
    – Seda
    Commented Apr 21, 2019 at 13:05

Not the answer you're looking for? Browse other questions tagged or ask your own question.