PHP Classes
elePHPant
Icontem

File: Example.php

Recommend this page to a friend!
  Classes of stefano dolzi  >  Combinatorics  >  Example.php  >  Download  
File: Example.php
Role: Example script
Content type: text/plain
Description: Example n.1
Class: Combinatorics
Make combinatorial statistics calculations
Author: By
Last change:
Date: 15 years ago
Size: 1,791 bytes
 

 

Contents

Class file image Download
<?php

/**
 *
 *
 * @version $Id$
 * @copyright 2003
 **/

include "Combinatorics.php";
// Calculate permutations
$mycalc=new Combinatorics;
$nperms=$mycalc->numPerm(5);
echo
"Number of possible permutations of 5 objects is " . $nperms;
echo
"</BR>";
// Permutations of objects
$perms=$mycalc->makePermutations(array("A","B","C","D","E"));
echo
"and they are the followings:</BR>";
foreach(
$perms as $key=>$value){
echo
$key .": ";
foreach (
$value as $key2=>$value2){
echo
$value2;
}
echo
"</BR>";
}
// Number combinations of objects without repetition
$ncombwr=$mycalc->numComb(4,2);
echo
"Number of possible combinations of 4 objects taken 2 by 2 without repetition is " . $ncombwr;
echo
"</BR>";
// Combinations without repetition
$combwr=$mycalc->makeCombination(array("A","B","C","D"), 2);
echo
"and they are the followings:</BR>";
foreach(
$combwr as $key=>$value){
echo
$key .": ";
foreach (
$value as $key2=>$value2){
echo
$value2;
}
echo
"</BR>";
}

//Number of dispositions of objects
$ndisp=$mycalc->numDisp(4,3 );
echo
"Number of possible dispositions of 4 objects taken 3 by 3 is " . $ndisp;
echo
"</BR>";
$disp=$mycalc->makeDisposition(array("A","B","C","D"), 3);
echo
"and they are the followings:</BR>";
foreach(
$disp as $key=>$value){
echo
$key .": ";
foreach (
$value as $key2=>$value2){
echo
$value2;
}
echo
"</BR>";
}
$ndispwr=$mycalc->numDispWoR(5,3 );
echo
"Number of possible dispositions of 5 objects without repetition taken 3 by 3 is ",$ndispwr ;
echo
"</BR>";
$dispwr=$mycalc->makeDispositionWoR(array("A","B","C","D","E"), 3);
echo
"and they are the followings:</BR>";
foreach(
$dispwr as $key=>$value){
echo
$key .": ";
foreach (
$value as $key2=>$value2){
echo
$value2;
}
echo
"</BR>";
}




?>