Learn R Programming

MoTBFs (version 2.0)

sample_motbfs: Generate Samples From an MoTBF Bayesian network

Description

This function generates a sample from an MoTBF Bayesian network.

Usage

sample_motbfs(bn, n, parallel = FALSE, evidence = NULL)

Value

A data.frame containing the generated sample. Is evidence is not NULL, attribute 'w' contains the weight of each sample.

Arguments

bn

An object of class motbf_fit, obtained from the function motbf.fit.

n

A non-negative integer giving the number of instances to be generated.

parallel

A logical value. If TRUE, parallelization is carried out. As a default, it is set to FALSE

evidence

A data.frame of one row containing the values for the observed variables. As a default, it is NULL.

Examples

Run this code
  data("ecoli", package = "MoTBFs")
  dat <- ecoli[,-c(1,4,5,9)]
  
  # Build DAG
  dag <- LearningHC(dat)
  
  # Learn BN parameters
  bn = motbf.fit(dag, dat)
 
 # Get sample from bn
 sam = sample_motbfs(bn, 50)
 
 

Run the code above in your browser using DataLab