function num_mutants = simulate_inherited_mutation_class
% simulate cell division over some number of generations. At each division,
% each non-mutated cell has a certain probability of mutation. Mutations
% are passed down from generation to generation.
mut_rate = 3e-6; % probability of mutation at each division.
% calibrated to yield ~1 mutant on average
n_0 = 1000; % number of cells in the first generation.
n_divisions = 7; % number of rounds of cell division
cells = zeros(n_0,1);
for i=1:n_divisions
cells_temp = cells; % duplicate the cells
mutators = rand(length(cells_temp),1) < mut_rate; % find cells that mutate
cells_temp(mutators | cells_temp) = 1; % cells stay mutated
cells = cat(1,cells,cells_temp); % concatenate mother and daughters
end
num_mutants = sum(cells); % total number of mutants