public DataSet simulateDataFisher(double[][] shocks,int intervalBetweenShocks,double epsilon){
  if (intervalBetweenShocks < 1)   throw new IllegalArgumentException("Interval between shocks must be >= 1: " + intervalBetweenShocks);
  if (epsilon <= 0.0)   throw new IllegalArgumentException("Epsilon must be > 0: " + epsilon);
  int size=variableNodes.size();
  if (shocks[0].length != size) {
    throw new IllegalArgumentException("The number of columns in the shocks matrix does not equal " + "the number of variables.");
  }
  setupModel(size);
  double[] t1=new double[variableNodes.size()];
  double[] t2=new double[variableNodes.size()];
  double[][] all=new double[variableNodes.size()][shocks.length];
  for (int row=0; row < shocks.length; row++) {
    for (int i=0; i < intervalBetweenShocks; i++) {
      for (int j=0; j < t1.length; j++) {
        t2[j]=shocks[row][j];
        for (int k=0; k < parents[j].length; k++) {
          t2[j]+=t1[parents[j][k]] * coefs[j][k];
        }
      }
      boolean converged=true;
      for (int j=0; j < t1.length; j++) {
        if (Math.abs(t2[j] - t1[j]) > epsilon) {
          converged=false;
          break;
        }
      }
      double[] t3=t1;
      t1=t2;
      t2=t3;
      if (converged) {
        break;
      }
    }
    for (int j=0; j < t1.length; j++) {
      all[j][row]=t1[j];
    }
  }
  List<Node> continuousVars=new ArrayList<>();
  for (  Node node : getVariableNodes()) {
    final ContinuousVariable var=new ContinuousVariable(node.getName());
    var.setNodeType(node.getNodeType());
    continuousVars.add(var);
  }
  BoxDataSet boxDataSet=new BoxDataSet(new VerticalDoubleDataBox(all),continuousVars);
  return DataUtils.restrictToMeasured(boxDataSet);
}

public DataSet simulateDataFisher ( double [ ] [ ] shocks , int intervalBetweenShocks , double epsilon ) { if ( intervalBetweenShocks < 1 ) throw new IllegalArgumentException ( "Interval between shocks must be >= 1: " + intervalBetweenShocks ) ; if ( epsilon <= 0.0 ) throw new IllegalArgumentException ( "Epsilon must be > 0: " + epsilon ) ; int size = variableNodes . size ( ) ; if ( shocks [ 0 ] . length != size ) { throw new IllegalArgumentException ( "The number of columns in the shocks matrix does not equal " + "the number of variables." ) ; } setupModel ( size ) ; double [ ] t1 = new double [ variableNodes . size ( ) ] ; double [ ] t2 = new double [ variableNodes . size ( ) ] ; double [ ] [ ] all = new double [ variableNodes . size ( ) ] [ shocks . length ] ; for ( int row = 0 ; row < shocks . length ; row ++ ) { for ( int i = 0 ; i < intervalBetweenShocks ; i ++ ) { for ( int j = 0 ; j < t1 . length ; j ++ ) { t2 [ j ] = shocks [ row ] [ j ] ; for ( int k = 0 ; k < parents [ j ] . length ; k ++ ) { t2 [ j ] += t1 [ parents [ j ] [ k ] ] * coefs [ j ] [ k ] ; } } boolean converged = true ; for ( int j = 0 ; j < t1 . length ; j ++ ) { if ( Math . abs ( t2 [ j ] - t1 [ j ] ) > epsilon ) { converged = false ; break ; } } double [ ] t3 = t1 ; t1 = t2 ; t2 = t3 ; if ( converged ) { break ; } } for ( int j = 0 ; j < t1 . length ; j ++ ) { all [ j ] [ row ] = t1 [ j ] ; } } List < Node > continuousVars = new ArrayList < > ( ) ; for ( Node node : getVariableNodes ( ) ) { final ContinuousVariable var = new ContinuousVariable ( node . getName ( ) ) ; var . setNodeType ( node . getNodeType ( ) ) ; continuousVars . add ( var ) ; } BoxDataSet boxDataSet = new BoxDataSet ( new VerticalDoubleDataBox ( all ) , continuousVars ) ; return DataUtils . restrictToMeasured ( boxDataSet ) ; }
simulates data using the model of r . a . fisher , for a linear model . shocks are applied every so many steps . a data point is recorded before each shock is administered . if convergence happens before that number of steps has been reached , a data point is recorded and a new shock immediately applied . the model may be cyclic . if cyclic , all eigenvalues for the coefficient matrix must be less than 1 , though this is not checked .
