NetworkSetRNG {RNetica}R Documentation

Sets a random number generator associates with the network.

Description

This function creates a new random number generator using the given seed and associates it with the network.

Usage

NetworkSetRNG(net, seed=sample.int(.Machine$integer.max,1L))

Arguments

net

An active NeticaBN whose random number generator is to be set.

seed

An unsigned integer to be uses as the seed.

Details

Associating a random number generator with a Netica network has two effects. First, if the seed is constant, then subsequent calls to GenerateRandomCase will create a reproducible sequence of cases. Second, as the default random number generator Netica uses is threadsafe, the random number generation will be slightly faster.

Value

Returns the net argument.

Note

This function both creates the random number generator (see NeticaRNG) and associates it with the network argument. Following the Netica API, it should be possible to separate the two operations, but it unclear what would happen if the RNG object was then freed (either manually or by associating it with another network and then deleting that other network). It therefore seemed safer to encapsulate the RNG creation process in the C code.

Author(s)

Russell Almond

References

http://norsys.com/onLineAPIManual/index.html: NewRandomGenerator_ns(), SetNetRandomGen_bn()

See Also

NeticaRNG, NewNeticaRNG(), GenerateRandomCase()

Examples

sess <- NeticaSession()
startSession(sess)

rnet <- CreateNetwork("Random", session=sess)
NetworkSetRNG(rnet, 1234469767)

DeleteNetwork(rnet)
stopSession(sess)


[Package RNetica version 0.7-3 Index]