Package 'ndgras'

Title: What the Package Does (Title Case)
Description: More about what it does (maybe more than one line). Continuation lines should be indented.
Authors: Jane Doe [aut, cre]
Maintainer: Jane Doe <[email protected]>
License: What license is it under?
Version: 0.1.0
Built: 2026-07-14 04:41:18 UTC
Source: https://github.com/UchidaMizuki/ndgras

Help Index


N-dimensional Generalized RAS (nD-GRAS) method

Description

N-dimensional Generalized RAS (nD-GRAS) method

Usage

nd_gras(
  source,
  constraints,
  ...,
  tolerance = 1e-10,
  max_iterations = 1000,
  verbose = FALSE
)

Arguments

source

An array to be adjusted.

constraints

A list of constraints created by nd_gras_constraint().

...

Additional arguments (currently unused).

tolerance

A numeric value indicating the convergence tolerance. Default is 1e-10.

max_iterations

An integer indicating the maximum number of iterations. Default is 1000.

verbose

A logical value indicating whether to print progress messages. Default is FALSE.

Value

A list containing the following components:

target

The adjusted n-dimensional array.

margins

A list of margins used in the constraints.

multipliers

A list of multipliers for each constraint.

iterations

The number of iterations performed.

max_change_multipliers

The maximum absolute difference between multipliers of the last two iterations.

converged

A logical value indicating whether the algorithm converged.


Create a constraint for the nD-GRAS method

Description

Create a constraint for the nD-GRAS method

Usage

nd_gras_constraint(margin, target)

Arguments

margin

An integer vector indicating the dimensions to constrain.

target

An array (or vector) representing the target marginal sums.

Value

A list containing the margin and target.