OrganizedDistribution

import java.util.*; /* public class OrganizedDistributionGenerator {
 * the purpose of this class is to take a given number of elements
 * and generate the "most organized" distributions with the min and max
 * entropy with this number of elements.
 * see
 * http://www.azim58.wikispaces.net/Maximum%2C+Minimum%2C+and+Intermediate+Entropy
 * http://www.azim58.wikispaces.net/Maximum%2C+Minimum%2C+and+Intermediate+Entropy

private int number_of_elements = 0; private ArrayList organized_distribution_max_entropy = new ArrayList; private double organized_distribution_max_entropy_entropy_value =0; private double organized_distribution_max_entropy_entropy_ratio =0; private ArrayList organized_distribution_min_entropy = new ArrayList; private double organized_distribution_min_entropy_entropy_value =0; private double organized_distribution_min_entropy_entropy_ratio =0; double max_possible_entropy = 0;

/** public static void main(String[] args) { //TODO Auto-generated method stub String final_string = ""; for(int i=3; i<10000; i++) { OrganizedDistributionGenerator odg = new OrganizedDistributionGenerator; final_string += odg.generateOrganizedDistributions(i)+"\n"; System.out.println(i); }
 * @param args

UsefulTools useful_tools = new UsefulTools; useful_tools.createTextFile("C:\\Users\\Owner\\Desktop\\temp", "Entropy of many distributions.txt", final_string); }

public String generateOrganizedDistributions(int number_of_elements) { String return_string = ""; this.number_of_elements = number_of_elements; OrganizedDistribution organized_distribution = new OrganizedDistribution; organized_distribution.initialize(number_of_elements); max_possible_entropy = organized_distribution.determineEntropyOfThisDistribution;

int highest_number_so_far = 1; boolean end_of_looped_reached = false; int current_number_of_ones = 0; while(end_of_looped_reached!=true) { current_number_of_ones = organized_distribution.getPoolOfOnesSize; if(current_number_of_ones>highest_number_so_far+1) { highest_number_so_far=highest_number_so_far+1; organized_distribution.addOtherNumber(highest_number_so_far); for(int i=0; i<highest_number_so_far; i++) { organized_distribution.subtract_from_pool_of_one; } } else { end_of_looped_reached = true; } }// store the organized distribution in it's current state into the max_entropy one

for(int i=0; i<organized_distribution.getSize; i++) { organized_distribution.assembleCompleteDistribution; organized_distribution_max_entropy.add(organized_distribution.getCompleteDistribtion.get(i).toString);

} organized_distribution_max_entropy_entropy_value = organized_distribution.determineEntropyOfThisDistribution; //now generate the organized_distribution_min_entropy int max_number = organized_distribution.getMaxOtherNumber; int number_of_ones = organized_distribution.getPoolOfOnesSize; int new_max_number = max_number+number_of_ones-1; organized_distribution.removeOtherNumber; organized_distribution.addOtherNumber(new_max_number); for(int i=0; i< number_of_ones-1; i++) { organized_distribution.subtract_from_pool_of_one; } for(int i=0; i<organized_distribution.getSize; i++) { organized_distribution.assembleCompleteDistribution; organized_distribution_min_entropy.add(organized_distribution.getCompleteDistribtion.get(i).toString);

} organized_distribution_min_entropy_entropy_value = organized_distribution.determineEntropyOfThisDistribution;

organized_distribution_max_entropy_entropy_ratio = organized_distribution_max_entropy_entropy_value/max_possible_entropy; organized_distribution_min_entropy_entropy_ratio = organized_distribution_min_entropy_entropy_value/max_possible_entropy;

return_string = number_of_elements+";"+organized_distribution_max_entropy.toString+";"+organized_distribution_max_entropy_entropy_value+";"+max_possible_entropy+";"+organized_distribution_max_entropy_entropy_ratio+";"+organized_distribution_min_entropy.toString+";"+organized_distribution_min_entropy_entropy_value+";"+max_possible_entropy+";"+organized_distribution_min_entropy_entropy_ratio;

return return_string; }

}