A city bike-share scheme has docking stations. Months of trip logs show how a single bike tends to move during one day:
P[i][j] is the probability that a bike which starts the day at station i ends that day at station j.P sums to , because a bike always ends the day somewhere.Tonight the fleet is fleet[i] bikes at station i. To plan the redistribution truck, the operator wants the expected number of bikes at each station after days more days.
Task: write fleet_forecast(P, fleet, days) returning a list with the expected number of bikes at each station after exactly days days, each rounded to 4 decimal places.
days is a whole number, 0 or more. After 0 days nothing has moved yet.P is square and its size matches fleet. Expected counts can be fractional, and that's fine.Once your function works, try one
Pwith a largedaysand two very different starting fleets, and compare the two answers.