What three factors affect the biodiversity of an ecosystem