diff --git a/articles/FAQ.html b/articles/FAQ.html index b7197f9d..4df0441d 100644 --- a/articles/FAQ.html +++ b/articles/FAQ.html @@ -75,7 +75,7 @@

Frequently Asked Questions

Marie Laure Delignette Muller, Christophe Dutang

-

2024-02-27

+

2024-03-20

Source: vignettes/FAQ.Rmd
FAQ.Rmd
@@ -1040,28 +1040,28 @@

This happens the C-base implementation of dlnorm takes care of the log value. In the file ../src/nmath/dlnorm.c in the R sources, we find the C code for dlnorm

-
double dlnorm(double x, double meanlog, double sdlog, int give_log)
-{
-    double y;
-
-#ifdef IEEE_754
-    if (ISNAN(x) || ISNAN(meanlog) || ISNAN(sdlog))
-    return x + meanlog + sdlog;
-#endif
-    if(sdlog <= 0) {
-    if(sdlog < 0) ML_ERR_return_NAN;
-    // sdlog == 0 :
-    return (log(x) == meanlog) ? ML_POSINF : R_D__0;
-    }
-    if(x <= 0) return R_D__0;
-
-    y = (log(x) - meanlog) / sdlog;
-    return (give_log ?
-        -(M_LN_SQRT_2PI   + 0.5 * y * y + log(x * sdlog)) :
-        M_1_SQRT_2PI * exp(-0.5 * y * y)  /  (x * sdlog));
-    /* M_1_SQRT_2PI = 1 / sqrt(2 * pi) */
-
-}
+
double dlnorm(double x, double meanlog, double sdlog, int give_log)
+{
+    double y;
+
+#ifdef IEEE_754
+    if (ISNAN(x) || ISNAN(meanlog) || ISNAN(sdlog))
+    return x + meanlog + sdlog;
+#endif
+    if(sdlog <= 0) {
+    if(sdlog < 0) ML_ERR_return_NAN;
+    // sdlog == 0 :
+    return (log(x) == meanlog) ? ML_POSINF : R_D__0;
+    }
+    if(x <= 0) return R_D__0;
+
+    y = (log(x) - meanlog) / sdlog;
+    return (give_log ?
+        -(M_LN_SQRT_2PI   + 0.5 * y * y + log(x * sdlog)) :
+        M_1_SQRT_2PI * exp(-0.5 * y * y)  /  (x * sdlog));
+    /* M_1_SQRT_2PI = 1 / sqrt(2 * pi) */
+
+}

In the last four lines with the logical condtion give_log?, we see how the log argument is handled: