function p_val = bic_smoothing_spline_range(x, y) vals_to_check = logspace(-7,-1, 1000); %.00000001:.00000002:.00005; counter = 0; for current_p = vals_to_check counter=counter+1; [f, goodness, output] = fit(x, y,'smoothingspline','SmoothingParam',current_p); %plot(f, x, y); %f.p, goodness, output bic_val(counter) = output.numobs*log(goodness.sse)+(output.numparam - 1)*log(output.numobs); end [junk,index]=min(bic_val); p_val = vals_to_check(index);