A computer-implemented method of determining the position of a mobile device, comprising the steps of: constructing a model for determining the position of a mobile device in a geographical area, wherein the model comprises: a graph comprising a set of vertices and a set of edges between the vertices; one or more feature functions that take as input one or more vertices of the graph and a set of observations for the device, and return a feature value; the method of constructing the model comprising the steps of: obtaining a map of the geographical area; constructing the graph using the map, wherein the vertices of the graph correspond to areas of the map, and two vertices are joined by an edge when the areas corresponding to the vertices are adjacent and can be travelled between by a device; building the one or more feature functions using the graph, wherein the feature value of a feature function of the one or more feature functions that takes as input one vertex of the graph indicates the extent to which the observations support the device being positioned in the area corresponding to that vertex of the graph, and wherein the feature value of a feature function of the one or more feature functions that takes as input more than one vertex of the graph indicates the extent to which the observations support the device moving between the areas corresponding to those vertices of the graph; obtaining a set of observations from the sensors of the device; determining the trajectory for the device that optimises the values given by the one or more feature functions for the set of observations; and determining the position of the device to be the end point of the trajectory. constructing a model for determining the position of a mobile device in a geographical area, wherein the model comprises: a graph comprising a set of vertices and a set of edges between the vertices; one or more feature functions that take as input one or more vertices of the graph and a set of observations for the device, and return a feature value; a graph comprising a set of vertices and a set of edges between the vertices; one or more feature functions that take as input one or more vertices of the graph and a set of observations for the device, and return a feature value; the method of constructing the model comprising the steps of: obtaining a map of the geographical area; constructing the graph using the map, wherein the vertices of the graph correspond to areas of the map, and two vertices are joined by an edge when the areas corresponding to the vertices are adjacent and can be travelled between by a device; building the one or more feature functions using the graph, wherein the feature value of a feature function of the one or more feature functions that takes as input one vertex of the graph indicates the extent to which the observations support the device being positioned in the area corresponding to that vertex of the graph, and wherein the feature value of a feature function of the one or more feature functions that takes as input more than one vertex of the graph indicates the extent to which the observations support the device moving between the areas corresponding to those vertices of the graph; obtaining a map of the geographical area; constructing the graph using the map, wherein the vertices of the graph correspond to areas of the map, and two vertices are joined by an edge when the areas corresponding to the vertices are adjacent and can be travelled between by a device; building the one or more feature functions using the graph, wherein the feature value of a feature function of the one or more feature functions that takes as input one vertex of the graph indicates the extent to which the observations support the device being positioned in the area corresponding to that vertex of the graph, and wherein the feature value of a feature function of the one or more feature functions that takes as input more than one vertex of the graph indicates the extent to which the observations support the device moving between the areas corresponding to those vertices of the graph; obtaining a set of observations from the sensors of the device; determining the trajectory for the device that optimises the values given by the one or more feature functions for the set of observations; and determining the position of the device to be the end point of the trajectory.