function [J] = genetic_ode_function_xt_minus_Ax(x, x_truth, xdot_truth) % % x is a population matrix of size [ N_pop x N_vars ] % % Written by: % -- % John L. Weatherwax 2006-08-28 % % email: wax@alum.mit.edu % % Please send comments and especially bug reports to the % above email address. % %----- [ N_pop, N_vars ] = size(x); [ N_t, x_dim ] = size(x_truth); power_of_pointwise_error = 3.; % maybe a power > 1 would do a better job selecting optimal population members J = zeros(N_pop,1); for pi=1:N_pop, % From the sample x, extract the matrix A: % A = reshape( x(pi,:), [x_dim,x_dim] ); xdot = ( A * x_truth.' ).'; % compute the norm between the truth and what we found when we solved the ODE with our given A and b: J(pi) = mean( sum( abs( xdot_truth - xdot ).^power_of_pointwise_error, 2 ).^(1./power_of_pointwise_error) ); end