A method for determining the posterior distribution of a probabilistic boosting tree, comprising: receiving input data at a graphics processing unit, GPU; determining (604, 606) a total posterior distribution value for the probabilistic boosting tree based on the input data by: pushing one or more nodes of the probabilistic boosting tree and a corresponding weight for each of the one or more nodes onto a stack; and for each node in the stack: calculating an empirical distribution for the node using a discriminative classifier associated with that node, if the node is a leaf node, weighting the empirical distribution for the node by the corresponding weight for the node and adding the weighted empirical distribution of the node to the total posterior distribution value, and if the node is a parent node that has child nodes, determining which child nodes are pushed onto the stack based on the value of the discriminative classifier of the parent node, and determining a weight for each child node pushed onto the stack, wherein the weight is a product of the weight of the parent node and a factor dependent on the value of the discriminative classifier of the parent node. receiving input data at a graphics processing unit, GPU; determining (604, 606) a total posterior distribution value for the probabilistic boosting tree based on the input data by: pushing one or more nodes of the probabilistic boosting tree and a corresponding weight for each of the one or more nodes onto a stack; and for each node in the stack: calculating an empirical distribution for the node using a discriminative classifier associated with that node, if the node is a leaf node, weighting the empirical distribution for the node by the corresponding weight for the node and adding the weighted empirical distribution of the node to the total posterior distribution value, and if the node is a parent node that has child nodes, determining which child nodes are pushed onto the stack based on the value of the discriminative classifier of the parent node, and determining a weight for each child node pushed onto the stack, wherein the weight is a product of the weight of the parent node and a factor dependent on the value of the discriminative classifier of the parent node. pushing one or more nodes of the probabilistic boosting tree and a corresponding weight for each of the one or more nodes onto a stack; and for each node in the stack: calculating an empirical distribution for the node using a discriminative classifier associated with that node, if the node is a leaf node, weighting the empirical distribution for the node by the corresponding weight for the node and adding the weighted empirical distribution of the node to the total posterior distribution value, and if the node is a parent node that has child nodes, determining which child nodes are pushed onto the stack based on the value of the discriminative classifier of the parent node, and determining a weight for each child node pushed onto the stack, wherein the weight is a product of the weight of the parent node and a factor dependent on the value of the discriminative classifier of the parent node. calculating an empirical distribution for the node using a discriminative classifier associated with that node, if the node is a leaf node, weighting the empirical distribution for the node by the corresponding weight for the node and adding the weighted empirical distribution of the node to the total posterior distribution value, and if the node is a parent node that has child nodes, determining which child nodes are pushed onto the stack based on the value of the discriminative classifier of the parent node, and determining a weight for each child node pushed onto the stack, wherein the weight is a product of the weight of the parent node and a factor dependent on the value of the discriminative classifier of the parent node. determining which child nodes are pushed onto the stack based on the value of the discriminative classifier of the parent node, and determining a weight for each child node pushed onto the stack, wherein the weight is a product of the weight of the parent node and a factor dependent on the value of the discriminative classifier of the parent node.