Needs-based resource allocation in education via formula funding of schools