ipfp: Function to run basic IPFP (iterative proportional fitting...

Description Usage Arguments Value Examples

View source: R/ipfp.R

Description

Use IPFP starting from x0 to produce vector x s.t. Ax = y within tolerance. Need to ensure that x0 >= 0.

Usage

1
2
ipfp(y, A, x0, tol = .Machine$double.eps, maxit = 1000, verbose = FALSE,
  full = FALSE)

Arguments

y

numeric constraint vector (length nrow)

A

constraint matrix (nrow x ncol)

x0

numeric initial vector (length ncol)

tol

numeric tolerance for IPFP; defaults to .Machine$double.eps

maxit

integer maximum number of iterations for IPFP; defaults to 1e3

verbose

logical parameter to select verbose output from C function

full

logical parameter to select full return (with diagnostic info)

Value

if not full, vector of length ncol containing solution obtained by IPFP. If full, list containing solution (as x), number of iterations (as iter), and norm of Ax - y (as errNorm)

Examples

1
2
3
4
5
6
7
A <- buildStarMat(3)
x <- rgamma(ncol(A), 10, 1/100)
y <- A %*% x
x0 <- x * rgamma(length(x), 10, 10)
ans <- ipfp(y, A, x0, full=TRUE)
print(ans)
print(x)

Example output

$x
[1]  375.3045  866.0663 1243.7942 1374.3889 1126.5777  823.2864  674.5356
[8]  883.8235 1101.4674

$iter
[1] 14

$errNorm
[1] 0

[1]  567.4434  793.7047 1124.0169 1136.4685 1183.0468 1004.7376  720.3171
[8]  899.7160 1039.7934

networkTomography documentation built on May 29, 2017, 4:56 p.m.