How to calculate the standard deviation in a transform?

Using scripted_metric its possibe to calculate that thanks for the guide