Algorithm-RandomMatrixGeneration

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

      my @result = generateMatrix(\@rmargs, \@cmargs, 3);
        
      Output matrix could be:
      0 2.694  1 9.665  2 0.393  3 0.258
      0 6.539  1 0.910  2 2.209  3 1.342
      0 8.469  1 3.565  2 0.839  3 0.127
      0 2.719  1 2.748  2 0.604  3 6.929
      0 0.946  1 3.771  2 5.939  3 1.344
      0 1.638  1 11.346  2 0.016

INPUTS
    The generateMatrix function can take 4 parameters:

    1. Single dimensional array containing row marginals (Can be real valued
    or integers) =item 2. Single dimensional array containing column
    marginals (Can be real valued or integers) =item 3. Precision: For the
    integer valued marginal specifying "-". For real valued marginals
    specify the required precision for the generated matrix values.
    (Recommended Precision = 4) =item 4. Seed: Seed for the random number
    generator (Default: None) (Optional parameter) =back

OUTPUT
        The generateMatrix function returns a two dimensional array
        containing the generated random matrix. The generated matrix is
        stored in sparse format in this returned array. That is, only
        non-zero values are stored in this matrix. Thus to access the values
        in the returned matrix one can use:

          for(my $row=0; $i<=$num_rows; $i++)
          {
                  for(my $col=0; $j<=$num_cols; $j++)
                  {

lib/Algorithm/RandomMatrixGeneration.pm  view on Meta::CPAN

  my @result = generateMatrix(\@rmargs, \@cmargs, 3);
	
  Output matrix could be:
  0 2.694  1 9.665  2 0.393  3 0.258
  0 6.539  1 0.910  2 2.209  3 1.342
  0 8.469  1 3.565  2 0.839  3 0.127
  0 2.719  1 2.748  2 0.604  3 6.929
  0 0.946  1 3.771  2 5.939  3 1.344
  0 1.638  1 11.346  2 0.016

=head1 INPUTS

The generateMatrix function can take 4 parameters:

=over 4

=item 1. Single dimensional array containing row marginals (Can be real valued or integers)
=item 2. Single dimensional array containing column marginals (Can be real valued or integers)
=item 3. Precision: For the integer valued marginal specifying "-". For real valued marginals specify the required precision for the generated matrix values. (Recommended Precision = 4)
=item 4. Seed: Seed for the random number generator (Default: None) (Optional parameter)
=back

=head1 OUTPUT

The generateMatrix function returns a two dimensional array containing the generated random matrix.
The generated matrix is stored in sparse format in this returned array. That is, only non-zero values 
are stored in this matrix. Thus to access the values in the returned matrix one can use: 

  for(my $row=0; $i<=$num_rows; $i++)
  {
	  for(my $col=0; $j<=$num_cols; $j++)
	  {
		  if(defined $returned_matrix[$row][$col])



( run in 0.343 second using v1.01-cache-2.11-cpan-4e96b696675 )