fixed return type of CalculatePartitionFunction