function [] = chap_1_prob_6(n) % % Written by: % -- % John L. Weatherwax 2007-07-01 % % email: wax@alum.mit.edu % % Please send comments and especially bug reports to the % above email address. % %----- %n = 10; P_sum = 0; for ii=1:n+1, P_sum = P_sum + prob_draw_first_colored_chip( ii, n ); end P_sum function p = prob_draw_first_colored_chip( k, n ) switch k case 1, p = 0; case 2, p = 1/n; otherwise, p = 1; for ii=1:k-2, p = p*(1-ii/n); end p = p*(k-1)/n; end