Stata 11 help for mf_normal
help mata normal()
-------------------------------------------------------------------------------
Title
[M-5] normal() -- Cumulatives, reverse cumulatives, and densities
Syntax
Gaussian normal:
f = normalden(z)
f = normalden(x, sd)
f = normalden(x, mean, sd)
p = normal(z)
z = invnormal(p)
ln(f) = lnnormalden(z)
ln(f) = lnnormalden(x, sd)
ln(f) = lnnormalden(x, mean, sd)
ln(p) = lnnormal(z)
Binormal:
p = binormal(z1, z2, rho)
Beta:
f = betaden(a, b, x)
p = ibeta(a, b, x)
q = ibetatail(a, b, x)
x = invibeta(a, b, p)
x = invibetatail(a, b, q)
Binomial:
pk = binomialp(n, k, pi)
p = binomial(n, k, pi)
q = binomialtail(n, k, pi)
pi = invbinomial(n, k, p)
pi = invbinomialtail(n, k, q)
Chi-squared:
p = chi2(n, x)
q = chi2tail(n, x)
x = invchi2(n, p)
x = invchi2tail(n, q)
F:
f = Fden(n1, n2, Fstat)
p = F(n1, n2, Fstat)
q = Ftail(n1, n2, Fstat)
Fstat = invF(n1, n2, p)
Fstat = invFtail(n1, n2, q)
Gamma:
f = gammaden(a, b, g, x)
p = gammap(a, x)
q = gammaptail(a, x)
x = invgammap(a, p)
x = invgammaptail(a, q)
dg/da = dgammapda(a, x)
dg/dx = dgammapdx(a, x)
d2g/da2 = dgammapdada(a, x)
d2g/dadx = dgammapdadx(a, x)
d2g/dx2 = dgammapdxdx(a, x)
Hypergeometric:
pk = hypergeometricp(N, K, n, k)
p = hypergeometric(N, K, n, k)
Negative binomial:
pk = nbinomialp(n, k, pi)
p = nbinomial(n, k, pi)
q = nbinomialtail(n, k, pi)
pi = invnbinomial(n, k, p)
pi = invnbinomialtail(n, k, q)
Noncentral Beta:
f = nbetaden(a, b, L, x)
p = nibeta(a, b, L, x)
x = invnibeta(a, b, L, p)
Noncentral chi-squared:
p = nchi2(n, L, x)
x = invnchi2(n, L, p)
L = npnchi2(n, x, p)
Noncentral F:
f = nFden(n1, n2, L, F)
q = nFtail(n1, n2, L, F)
F = invnFtail(n1, n2, L, q)
Poisson:
pk = poissonp(mean, k)
p = poisson(mean, k)
q = poissontail(mean, k)
m = invpoisson(k, p)
m = invpoissontail(k, q)
Student's t:
f = tden(n, t)
q = ttail(n, t)
t = invttail(n, q)
where
1. All functions return real and all arguments are real.
2. The left-hand-side notation is used to assist in interpreting the
meaning of the returned value:
f = density value
pk = probability of discrete outcome K = Pr(K = k)
p = left cumulative
= Pr(-infinity < statistic < x) (continuous)
= Pr(0 < K < k) (discrete)
q = right cumulative
= 1 - p (continuous)
= Pr(K > k) = 1 - p + pk (discrete)
3. Hypergeometric distribution:
N = number of objects in the population
K = number of objects in the population with the
characteristic of interest, K < N
n = sample size, n < N
k = number of objects in the sample with the
characteristic of interest,
max(0,n-N+K) < k < min(K,n)
4. Negative binomial distribution: n > 0 and may be nonintegral.
Description
The above functions return density values, cumulatives, reverse
cumulatives, and in one case, derivatives of the indicated probability
density function. These functions mirror the Stata functions of the same
name and in fact are the Stata functions.
See [D] functions for function details. In the syntax diagram above,
some arguments have been renamed in hope of aiding understanding, but the
function arguments match one to one with the underlying Stata functions.
Remarks
Remarks are presented under the following headings:
R-conformability
A note concerning invbinomial() and invbinomialtail()
A note concerning ibeta()
A note concerning gammap()
R-conformability
The above functions are usually used with scalar arguments and then
return a scalar result:
: x = chi2(10, 12)
: x
.7149434997
The arguments may, however, be vectors or matrices. For instance,
: x = chi2((10,11,12), 12)
: x
1 2 3
+-------------------------------------------+
1 | .7149434997 .6363567795 .5543203586 |
+-------------------------------------------+
: x = chi2(10, (12,12.5,13))
: x
1 2 3
+-------------------------------------------+
1 | .7149434997 .7470146767 .7763281832 |
+-------------------------------------------+
: x = chi2((10,11,12), (12,12.5,13))
: x
1 2 3
+-------------------------------------------+
1 | .7149434997 .6727441644 .6309593164 |
+-------------------------------------------+
In the last example, the numbers correspond to chi2(10,12),
chi2(11,12.5), and chi2(12,13).
Arguments are required to be r-conformable (see help [M-6] glossary), and
thus,
: x = chi2((10\11\12), (12,12.5,13))
: x
1 2 3
+-------------------------------------------+
1 | .7149434997 .7470146767 .7763281832 |
2 | .6363567795 .6727441644 .7066745906 |
3 | .5543203586 .593595966 .6309593164 |
+-------------------------------------------+
which corresponds to
1 2 3
+-------------------------------------------+
1 | chi2(10,12) chi2(10,12.5) chi2(10,13) |
2 | chi2(11,12) chi2(11,12.5) chi2(11,13) |
3 | chi2(12,12) chi2(12,12.5) chi2(12,13) |
+-------------------------------------------+
A note concerning invbinomial() and invbinomialtail()
invbinomial(n, k, p) and invbinomialtail(n, k, q) are useful for
calculating confidence intervals for pi, the probability of a success.
invbinomial() returns the probability pi such that the probability of
observing k or fewer successes in n trials is p. invbinomialtail()
returns the probability pi such that the probability of observing k or
more successes in n trials is q.
A note concerning ibeta()
ibeta(a, b, x) is known as the cumulative beta distribution, and it is
known as the incomplete beta function I_x(a, b).
A note concerning gammap()
gammap(a, x) is known as the cumulative gamma distribution, and it is
known as the incomplete gamma function P(a, x).
Conformability
All functions require that arguments be r-conformable; see
R-conformability above. Returned is matrix of max(argument rows) rows
and max(argument columns) columns containing element-by-element
calculated results.
Diagnostics
All functions return missing when arguments are out of range.
Source code
Functions are built in.
Also see
Manual: [M-5] normal()
Help: [M-4] statistical
|