TITLE: How to get the standard deviation of a given histogram (image)
QUESTION [12 upvotes]: I have a doubt:
How to get the standard deviation of a given histogram?
I'm looking for it on the internet. But I got Nothing. 
For example the case of this image below

Thanks in advance!

REPLY [3 votes]: If you'd like to get Adam Hughes' answer code in python please find it below.
The testcase gives:
{'n': 9, 'sum': 100, 'prod': 2694, 'sqsum': 363.64, 'mean': 26.94, 'variance': 3.6364, 'stdv': 1.9069347130932406}

testcase:
def test_Stats():
    # https://math.stackexchange.com/questions/857566/how-to-get-the-standard-deviation-of-a-given-histogram-image
    values=[(23,3),(24,7),(25,13),(26,18),(27,23),(28,17),(29,8),(30,6),(31,5)]
    stats=Stats(values)
    print (vars(stats))

Code
class Stats:
    """ Calculate Histogram statistics see https://math.stackexchange.com/questions/857566/how-to-get-the-standard-deviation-of-a-given-histogram-image """
    def __init__(self,histindexed):
        self.n=len(histindexed)
        self.sum=0
        self.prod=0
        self.sqsum=0
        for x,y in histindexed:
            self.sum+=y
            self.prod+=x*y
        self.mean=self.prod/self.sum
        for x,y in histindexed:
            dx=x-self.mean
            self.sqsum+=y*dx*dx
        # σ²
        self.variance=self.sqsum/self.sum
        self.stdv=math.sqrt(self.variance)