computing perplexity