How to return correct percentiles?

Hi!
I tried to let ChatGPT 4 calculate der percentiles of some rows we had. It did calculate them but the results were just wrong. Now I am looking for a way to get correct results. I tried to give him precise instructions like: “Here is the table. Please add another row and calculate the 2.5 percentile for this coloumn.”
As said - he basically did it but not in a correct way.

I tried it as well with chatgpt 3.5. I had 100 values and asked for the 95th percentile. But it was never the right value.

Thanks for any hints.

Hi

Welcome to the community.
This is an increasingly common type of question on the forum. So forgive me that I ran it through ChatGPT …

I understand that you’re having trouble with ChatGPT calculating percentiles correctly. While ChatGPT is a powerful language model, it may not always be the best tool for precise calculations, especially in the context of percentiles. In this case, I would recommend using a dedicated statistical software or programming language like Python to achieve the desired results. For instance, in Python, you can use the NumPy library to calculate percentiles accurately. Here’s an example code snippet for calculating the 95th percentile of a list of values:

It goes on to provide an example of code.

That is basically the answer I would have written. But not as eloquently.

I hope that is helpful

1 Like

Unfortunately this doesn’t help either - at lest not in gpt 3.5 (can’t test in 4.0 right now).

He gives me the following code:

import numpy as np

Create an example data set

data = np.array([50.6, 51.0, 51.1, 52.4, 53.1, 53.1, 53.3, 54.1, 54.6, 54.6,
55.3, 55.6, 55.8, 56.6, 57.4, 58.0, 58.2, 58.2, 58.6, 58.7,
59.6, 59.8, 60.3, 60.8, 60.9, 60.9, 61.1, 61.2, 61.3, 61.6,
61.6, 62.1, 62.2, 62.2, 63.0, 63.4, 63.6, 63.8, 63.9, 64.4,
64.6, 64.8, 65.0, 65.1, 65.3, 66.0, 66.6, 66.8, 66.8, 66.9,
67.0, 67.1, 67.8, 67.8, 67.9, 68.1, 68.3, 68.6, 68.7, 69.0,
69.4, 69.5, 69.8, 69.9, 70.4, 70.5, 70.6, 70.6, 70.9, 71.0,
71.3, 72.6, 72.9, 73.3, 73.7, 74.3, 75.2, 75.2, 75.3, 75.3,
75.9, 76.1, 78.0, 78.2, 79.1, 79.2, 81.2, 81.2, 81.6, 81.6,
81.7, 86.4, 93.4, 94.8, 102.0, 102.1])

Calculate the 95th percentile

p95 = np.percentile(data, 95)

Print the result

print("95th percentile: ", p95)

with the result of 102.1 - which is obviously wrong since it is th 100th value.

Asking about that:

So… the snippet it wrote is run by chatgpt but… the result is wrong?

PS: And yeah… I really love how chatgpt replaced on many occasions long searches using google, bing, ddg and so on :smiley:

I think my point did not translate well.

The various GPT models available are large language models. Their ability to do maths is a function of seeing maths during language training. But it is not trained to do maths. So while it looks like it can do some mathematics—giving correct answers some of the time, always attempting to give an answer and never saying it can’t—that is not its strength nor purpose.

1 Like

Thank you for your answer again. Ofc you are right.
After your initial answer and my reply I was interested how he could come up with 1 + 1 = 2 though. As far as I understand it now he is only restricted to words and searches. He basically ‘knows’ that 1+1=2 but more complex stuff - there is nothing you could know or search for… right? So a longer stream of numbers - he can’t calculate but rather goes looking for a solution that he might already know. Did I get that correctly?

Then I also thought he would be able to run the code but - yeah… that it unfortunately not possible.

Still very useful.
For everyone who has a similar problem - it could be solved that way: You just need to use kaggle that can easily run python with no additional effort besides creating an account. Make a notebook in kaggle, copy the code you got from chatgpt and you are ready to go. Also tried it with boxplots. There are python functions that can do those as well. I am pretty happy right now.

The models can do simple math like add “1 + 12 + 7 + 10” semi reliably if they can see their work. Anything beyond grade school math forget it…

Both GPT-3.5 & 4, are inherently bad at math, you can sometimes use it to create code that will calculate the correct answer, it that fails I’ll suggest using a spreadsheet or calculator.

I’ve written some more about it over in this thread:

1 Like