Title: | Estimates Parameters of Functions Driving Binomial Random Variables |
---|---|
Description: | Provides maximum likelihood estimates of the performance parameters that drive a binomial distribution of observed errors given signal-to-noise ratios, and takes full advantage of zero error observations. High performance communications systems typically have inherent noise sources and other performance limitations that need to be estimated. Measurements made at high signal to noise ratios typically result in zero errors due to limitation in available measurement time. Package includes theoretical performance functions for common modulation schemes (Proakis, "Digital Communications" (1995, <ISBN:0-07-051726-6>)), including polarization shifted QPSK (Agrell & Karlsson (2009, <DOI:10.1109/JLT.2009.2029064>)), and utility functions to work with the performance functions. |
Authors: | Philip Shea [aut, cre] |
Maintainer: | Philip Shea <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.0.9000 |
Built: | 2025-02-14 05:42:29 UTC |
Source: | https://github.com/philshea/binfunest |
Creates a function f( -dB( undB( -s) + undB( -B2B)) - offset)
B2BConvert(f)
B2BConvert(f)
f |
A function of a single argument |
Note that all quantities are assumed to be in Decibels.
A function of three arguments function( x, B2B, offset){...}
where x
is the symbol SNR, B2B
is the back-to-back SNR (i.e. the
equivalent SNR when the input SNR (x
) is infinite), and offset
is
the offset to the function f
(i.e., if B2B
where infinite).
QPSKdB.B2B <- B2BConvert( QPSKdB)
QPSKdB.B2B <- B2BConvert( QPSKdB)
BERDF
dataframe created by simsigs()
, a function in a
forthcoming package coherent
.BERDF
is a standard R
data frame created by the simsigs()
function in
the forthcoming coherent
package. The observations have been condense
d
BERDFc
BERDFc
A dataframe with the following fields:
Name of constellation used to create the record.
The SNR in Decibles of the observation.
The number of bits per symbol. The number of bits in a
simulation run is Bps * N
The actual noise power in the simulation run. Since the noise is randomly generated, this is a stochastic item.
The number of symbols in the simulation run.
The number of symbols errors observed in the simulation run.
The number of bit errors observed in the simulation run.
This simple function will return the correlation matrix for mle
fits of
more than one variable. Note that this function is not an S3 generic.
cor.mle(m)
cor.mle(m)
m |
an |
a symmetric matrix with ones on the diagonal.
Q_ab <- function( gamma, a, b) cor.mle( mle1)
Q_ab <- function( gamma, a, b) cor.mle( mle1)
Bit error counts modeled as independent binary decisions result in a
log-likelihood dependent on the bit error probability. This function
inserts the supplied bit error probability function into the binomial
log-likelihood function, and passes that to stats4::mle, which ultimately
calls stats::optim. The function will optimize a binomial probability
of the form $r = N * P( x_1, x_2, ..., x_n, a_1, a_2, ... a_k)$, where the
$x_i$ are variables from data
, and the $a_j$ are parameters to be
estimated.
mleB2B(data = NULL, Errors, N, f, fparms, start, method = "Nelder-Mead", ...)
mleB2B(data = NULL, Errors, N, f, fparms, start, method = "Nelder-Mead", ...)
data |
a data frame or list with named components. If a list, each component must be the same length (just like a data frame). This is not checked, so usual rules of recycling will apply. Partial matching not performed, so you must use full column names. |
Errors |
A vector of error counts, or a string identifying a column of
|
N |
A single number, or a vector of the same length as
|
f |
A function that predicts the probability of errors. |
fparms |
a list of named components that are the arguments of |
start |
Named list of initial values for the parameters of |
method |
Optimization method. See |
... |
Optional arguments to be passed to mle. |
The function estimates the parameters identified in start
in the
constructed call to f
. For a function f
of the form
fun( SNR, x2, x3, B2B, offset)
A call of the form
mleB2B( data=df, Errors="r", N="trials", f=fun,
fparm=list( SNR="s", x2=1, x3="noise"), start=list(B2B=1, offset=2))
will construct a call to mle
of the form:
mle( minuslogl=ll, start=start, nobs=length( Errors), method=method)
where the function ll
is defined as
ll <- function( a, b) -sum( dbinom( df$r, df$n,
fun( SNR=df$s, x2=1, x3=df$noise, B2B=B2B, offset=offset),
log=TRUE))
An object of class stats4::mle with the parameters
identified in start
estimated.
QPSKdB.B2B <- B2BConvert( QPSKdB) O1 <- 3 B1 <- 16 s <- 0:20 N <- 1000000 r <- rbinom( length( s), N, QPSKdB.B2B( s, B1, O1)) df <- data.frame( Errors=r, SNR=s, N=N) llsb2 <- function( b2b, offset) -sum( dbinom( r, N, QPSKdB.B2B( s, b2b, offset), log=TRUE)) mle1 <- stats4::mle( llsb2, start=c( b2b=20, offset=0), nobs=length(s), method="Nelder-Mead") est1 <- mleB2B( data=df, Errors="Errors", N=N, f=QPSKdB.B2B, fparms=list( x="SNR"), start=c(b2b=20, offset=0))
QPSKdB.B2B <- B2BConvert( QPSKdB) O1 <- 3 B1 <- 16 s <- 0:20 N <- 1000000 r <- rbinom( length( s), N, QPSKdB.B2B( s, B1, O1)) df <- data.frame( Errors=r, SNR=s, N=N) llsb2 <- function( b2b, offset) -sum( dbinom( r, N, QPSKdB.B2B( s, b2b, offset), log=TRUE)) mle1 <- stats4::mle( llsb2, start=c( b2b=20, offset=0), nobs=length(s), method="Nelder-Mead") est1 <- mleB2B( data=df, Errors="Errors", N=N, f=QPSKdB.B2B, fparms=list( x="SNR"), start=c(b2b=20, offset=0))
Functions to calculate the theoretical performance of common modulation
formats. Includes the functions dB(x)
(returns 10*log10(x)
), undB(x)
(reverses dB(x)
), Q_( x)
(Markum's Q function), and Q_Inv(x)
(returns the
SNR in Decibels to get probability x). Also includes mod_Inv
, which returns
the SNR required for a the function f
to reach the supplied BER (bit
error rate, or bit error probability).
is.wholenumber(x, tol = sqrt(.Machine$double.eps)) dB(x) undB(x) Q_(x) Q_Inv(perr) marcumq(a, b, m = 1) QPSKdB(x) DBPSKdB(x) DQPSKdB(x) DQPSKDDdB(x) PSQPSKdB(x) MPSKdB(x, M) MPSKdB.8(x) QAMdB.8.star(x) QAMdB(x, M) QAMdB.16(x) mod_Inv(f, perr, guess = Q_Inv(perr)) mod_InvV(f, pv, offset = 0)
is.wholenumber(x, tol = sqrt(.Machine$double.eps)) dB(x) undB(x) Q_(x) Q_Inv(perr) marcumq(a, b, m = 1) QPSKdB(x) DBPSKdB(x) DQPSKdB(x) DQPSKDDdB(x) PSQPSKdB(x) MPSKdB(x, M) MPSKdB.8(x) QAMdB.8.star(x) QAMdB(x, M) QAMdB.16(x) mod_Inv(f, perr, guess = Q_Inv(perr)) mod_InvV(f, pv, offset = 0)
x |
a real number |
tol |
the tolerance to test x with. |
perr |
a probability of a bit error. |
a , b , m
|
|
M |
The integer number of symbols > 4. |
f |
a function (usually a BER function). |
guess |
a guess for the |
pv |
a vector of BERs. |
offset |
an offset in Decibels for guesses in |
The marcumq
function is copied from the gsignal
package, which copied it
from the help file of the lmomco
package, but is clear from Proakis
equations 2-1-121 and 2-1-124.
The rest of the functions return the probability of a bit error given the SNR in Decibels.
QPSKdB
is Quadrature Phase shift keyed: two bits per symbol. Note that
BPSK and QPSK have the same performance when SNR is $E_b/N_0$.
DBPSKdB
is differentially detected differential binary PSK.
DQPSKdB
is differentially detected differentially coded QPSK.
DQPSKDDdB
is differentially decoded differential QPSK (coherently
detected but differentially decoded. See DQPSK
above.
PSQPSKdB
is polarization-shifted QPSK: it is dual pole, but only
one pole is active at any one time, thus supplying three bits per
symbol. (See Agrell & Karlsson (2009, DOI:10.1109/JLT.2009.2029064)).
MPSKdB(x, M)
is generic M-ary phase shift keying of M
points in a circle.
MPSKdB.8
simply returns MPSKdB(x, 8)
QAMdB.8.star
is the optimal star configuration of 8-ary Quadrature
Amplitude Modulation (QAM), such that
the legs are at and
.
QAMdB(x, M)
is generic rectangular QAM constellation of M
points.
QAMdB.16
Returns the BER for the rectangular QAM constellation according to
Proakis Eq. 5-2-80.
mod_Inv
will take a function f(x)
and return the x such that
f(x)==perr
but it does this based on the log( f(x))
and the log( perr)
, so
f(x)>0
.
mod_InvV
is a vectorized version (give it a vector of BERs and it returns a
vector of SNRs).
is.wholenumber(x)
returns TRUE
if c-round(x) < tol
.
dB(x)
returns 10*log10(x)
undB(x)
returns 10^(x/10)
Q_Inv(x)
returns 2*dB( -qnorm(x))
, which is the
SNR (in Decibels) required to get a probability of error of x.
Q_Inv( Q_( undB( x/2))) = x and Q_( undB( Q_Inv( x)/2))=x
mod_Inv( f, x)
returns a list with the SNR in Decibels to
reach the BER
perr
such that f( mod_Inv( f, x)$x) = x
.
The returned list has elements
$x
as the SNR and
$fval
as the function value.
https://cran.r-project.org/package=lmomco
https://cran.r-project.org/package=gsignal
dB( 10) # == 10 undB( 20) # == 100 Q_Inv( Q_( undB( 10/2))) # = 10 Q_( undB( Q_Inv( 0.001)/2)) # = 0.001 mod_Inv( QPSKdB, QPSKdB( 7)) # yields 7 mod_InvV(QPSKdB, QPSKdB(c(6,7)))
dB( 10) # == 10 undB( 20) # == 100 Q_Inv( Q_( undB( 10/2))) # = 10 Q_( undB( Q_Inv( 0.001)/2)) # = 0.001 mod_Inv( QPSKdB, QPSKdB( 7)) # yields 7 mod_InvV(QPSKdB, QPSKdB(c(6,7)))