It is common practice to share a histogram of grades with a class after a quiz or exam. However, my institute has very small classes. This year I have 6 students in my class, and in previous years I have had 3. It seems like showing the breakdown of grades (e.g. how many A's, B's, C's there were) in such a small class may be inappropriate, since students may easily be able to guess who got which grade. On the other hand, it seems only fair to tell students how they did relative to the rest of the class.
You probably want to check with your university policy on grade sharing so you don't wander into a problem with your local regulatory body.
As for my opinion:
I am from the US so the following examples are based on the Family Educational Rights and Privacy Act (FERPA), however they may be useful to you anyway.
Speaking from a STEM prospective, at my university in the very large auditorium classes, and even smaller (30-50 student) classes histograms were regularly either mentioned after the test or posted. It was very useful for a student to know, based on their grade, what percentile they fit into. For me, it helped me understand if I really understood the material or I was carried by a curve. Due to this I consider posting a distribution (anonymous) a highly useful tool for your students that actually care about their grade. In advanced classes where curves are common this could help them if they need to ask for more resources.
It's reasonable (albeit maybe not FERPA reasonable) to assume that as long as the grades are anonymous and the percentiles group into large enough bins students can't deduce other students exact grade which may be the loophole (discussed in the links below).
On the other hand you have small classes. Sharing a distribution of 10 students for example may give too much information to your students about other student's grades. Again, FERPA is the problem here. Is anonymous distribution of grades enough to protect you from an angry student? You may want to check your university teaching guide. If FERPA isn't an issue then it really comes down to if you think it will provide students some value. I can see it both ways. What information could the grade distribution of 3-6 students (for example) provide to the students? Not much I think.
There are some good points here posted by people on both sides. I don't personally see a problem with it (your case I lean more towards not doing it however) but FERPA is a headache and you are probably best not asking here, but rather asking your university.
There are some links on the web related to FERPA that may be similar to your local policy:
This link (non-edu) seems to imply the grade distribution falls outside the scope of grade disclosure rules.
This USC guide says grade posting is fine as long as student names are anonymized with a unique code and non-alphabetically listed.
CCCOnline seems to support posting grade distributions as being okay with FERPA.
ASU says something similar to the USC guide.
This UMSL link Says teachers are responsible for coming up with a way of distributing grades such that no student knows the other's grade.
A comment has brought to my attention you may not be from the US. Unfortunately, I wasn't able to find a similar depth of resources compared to FERPA through Google and I have no experience with European law regarding grade distribution. I found the following AACRAO working group paper on the GDPR unfortunately it provides situations and questions but not answers. I apologize. As always, refer to your University for the final say on these matters.
Check if the university has a policy on this. This varies wildly across locations: in some places grades are still published with the students' names next to them; in others there are stated policies that this is not allowed. At my university, histograms are automatically published by the system no matter the number of students (even if 2), and there is no way to prevent this.
If there is no policy on this, it is your choice how much you want to weigh transparency vs data protection. There are also intermediate options, such as only publishing the mean, maximum and minimum grade, or the mean amd variance.
I take issue with your premise:
It seems only fair to tell students how they did relative to the rest of the class
In a large class, this seems reasonable: if I know that I'm in the top 5%, I know that I am likely to get an A, regardless of my actual score. Even professors who "don't curve" usually adjust difficulty levels to achieve the desired outcome.
In a class with three students, this is not really the case -- giving three As or three Cs could be appropriate. Saying "you got the top score" doesn't really provide any information about my performance. So, I would argue that it provides no upside. Others have already covered the downside - namely, privacy violations.
I would suggest a better option would be to say: "Scores above 80 are A-range, 65 is B-range, 50 is C-range." This is both more useful to the student and sidesteps any privacy issue.
I'm not sure how "common" it is to share a histogram, but I question the value of it. I also worry that it implies in some way that grading is competitive. The worst case, of course, is a zero-sum grading system in which to give person A a point, person B must be denied a point. That is evil. In fact, grading "on the curve" has this characteristic built in. Students are individuals and should be treated as individuals, not as statistics.
But, I wonder why you think it is desirable to post relative scores. What does that add to the educational process? Who does it benefit? Who does it discourage? If education is about "bragging rights" or "one-upmanship" then fine. But telling a student that they were worse than most of their peers is not, IMO, a way to encourage them to learn. Rather, it can lead to depression.
I suggest, instead, that grading be individual and that the philosophy is that everyone can earn top marks, as well as that everyone can fail.
Students need feedback, of course, but the feedback should be related to their own performance, not the performance of others. Education isn't a sporting event.
A histogram may be useful to the instructor, I think, but making it public, even in a large class, can be counterproductive.
As much as the other answers are correct, there is an alternative solution if you indeed want to release the grade distributions without compromising on anonymity. You can use differential privacy (ε-differential privacy with a random response in this case seems applicable) to guarantee that no information can be gained regarding individuals grades, even if there is only one person in the class, while still ensuring statistical measures performed on the grades remain the same.
Differential privacy uses statistics to guarantee that anonymity is retained, by affording plausible deniability, while also ensuring statistical accuracy, and is widely used these days by companies wanting to make data releases (such as Google or Apple). The drawback of this is the grades you are releasing are only statistically accurate (to within a controlled threshold), but the individual grades themselves may or may not be correct.
I'd say in this case where the data has been thoroughly anonymized using these methods (as opposed to k-anonymity or l-diversity which have their drawbacks in small group sizes), then releasing this information poses no risk to individuals.
You can then take this one step further and release a distribution based on these anonymized grades, while still retaining the guarantee that individual grades cannot be obtained by any party.
It'd still be good to check academic policy, but in any case, this is a good measure to take if you want to protect your students.
The 'transaction' you and your students are engaged in is between you [the university] and themselves [the student]. If you are secure that your assessment was adequate and fair, there is nothing to be gained in comparing students against each other, especially publicly. If you are not secure in your testing methodology, you might consider grading on a curve, which by definition compares individuals against each other, but again, this need not be a public exercise.