Learn R Programming

cgraph (version 6.0.1)

approx_gradient: Approximate Gradient

Description

Differentiate a target node with respect to a given node by numerical differentiation.

Usage

approx_gradient(graph, target, node, index = 1, eps = 1e-04)

Arguments

graph

cg_graph object, graph that is differentiated.

target

cg_node object, node in the graph that is differentiated. Alternatively, argument target can be a character scalar denoting the name of the node in the graph that is differentiated.

node

cg_node object, node with respect to which the target node is differentiated. Alternatively, argument node can be a character scalar denoting the name of the node in the graph to which the target node is differentiated.

index

numerical scalar, index of the target node that is differentiated. Defaults to the first element.

eps

numerical scalar, step size. Defaults to 1e-4.

Value

numerical vector or array.