1
$\begingroup$

I’m doing a programming assignment on sample gamma distributions in R. I used a loop to create histograms of a total of 49 different samples, each with different parameters. I was then asked to compare the theoretical mean and variance to the sample mean and variance for each of the 49 cases. I used a loop to create vectors of each of the sample means etc. However, I am getting answers such as (1.0e+00) where in this case, the answer should just be one. How do I solve this problem? I hope Ive given enough information and am making sense, if not I can clarify further, I have never done any probability programming so I’m relatively new to it.

$\endgroup$
1
  • 2
    $\begingroup$ Is this a formatting issue? 1.0e+00 means $1 \times 10^0$ and that is $1$ $\endgroup$ – Henry Mar 19 '20 at 15:08
1
$\begingroup$

Your programming efforts are probably correct, but you might not be familiar with E notation. It's quite widely used in programming contexts and one of the default output formats of R.

The part after the e is the exponent of 10, so $10^{0}$, and you need to multiply that by the part before the e. This yields $1 \times 1.0 = 1$, as you expected.

As described here on Stack Overflow (and in the other answer), you can disable it with options(scipen = 999) and it's possible to put that in your .Rprofile file so it becomes the default for you.

$\endgroup$
0
$\begingroup$

If this is a formatting issue, just run the following command which will suppress the scientific notation:

options(scipen = 9999)
$\endgroup$

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