def generate_mc(self, n_trials, tol=1.e-2): factor = self.get_factor() mc_fudge = helpers.get_mc(self.Ncat, self.Nitems, n_trials, factor, tol) return mc_fudge
from scipy import optimize, stats import numpy as np import helpers # Run once to compile the functions print("Compiling the functions...") print(helpers.one_trial_div2(20, 60)) print(helpers.get_tree_fudge_multi(20, 60, 2)) print(helpers.Ptree(20, 10)) print(helpers.f_empty(20, 10)) print(helpers.n_filled(20, 10)) print(helpers.cdf(20)) print(helpers.get_mc(20, 60, 2, 10)) class Counts(object): """Class that reads a counts filename and holds all the operations we want to do""" def __init__(self, fname): """Read a file of (sorted) counts""" self.counts = np.sort(np.loadtxt(fname))[::-1] self.Ncat = len(self.counts) self.Nitems = np.sum(self.counts) self.frequencies = self.counts / self.Nitems self.ranks = np.arange(1, self.Ncat + 1) def get_cdf(self): cdf_counts = self.Nitems * 0.5**np.arange(1, self.Ncat + 1) cdf = helpers.cdf(self.Ncat) return np.vstack((cdf_counts, cdf))
from scipy import optimize, stats import numpy as np import helpers # Run once to compile the functions print("Compiling the functions...") print(helpers.one_trial_div2(20, 60)) print(helpers.get_tree_fudge_multi(20, 60, 2)) print(helpers.Ptree(20, 10)) print(helpers.f_empty(20, 10)) print(helpers.n_filled(20, 10)) print(helpers.cdf(20)) print(helpers.get_mc(20, 60, 2, 10)) class Counts(object): """Class that reads a counts filename and holds all the operations we want to do""" def __init__(self, fname): """Read a file of (sorted) counts""" self.counts = np.sort(np.loadtxt(fname))[::-1] self.Ncat = len(self.counts) self.Nitems = np.sum(self.counts) self.frequencies = self.counts/self.Nitems self.ranks = np.arange(1, self.Ncat+1) def get_cdf(self): cdf_counts = self.Nitems * 0.5**np.arange(1, self.Ncat+1) cdf = helpers.cdf(self.Ncat)