Data fusion and filtering via calculus of variations