3 Replies Latest reply on Feb 1, 2018 9:02 AM by patrick.byrne.0

    Using TabPy to make a Normal Curve

    Pragyan Bezbaruah

      I have before made Normal curves using the amazing blog by Robin Kennedy:

      https://public.tableau.com/en-us/s/blog/2013/11/fitting-normal-curve-histogram

       

      But when it comes to TabPy, I am failing to do so. As using Python codes inside Tableau needs some tweaking to do, some of the basic functions of Python fail in Tableau.

       

      Even if I go step by step with the blog and manipulating the code as TabPy needs me to work, the final formula to make the curve -

       

      (1 / ([St Dev] * SQRT(2*PI()))) * EXP(-((ATTR([Profit Bin]) – [Mean])^2 / (2*[St Dev]^2))) * [Profit Bin Size]* TOTAL (SUM([Number of Records]))

       

      is rather getting difficult for me to recreate.

       

      What I wrote till now is -

      SCRIPT_REAL("

      import numpy as np

      import matplotlib.mlab as mlab

      import math

       

       

      sigma = maths.sqrt(_arg1)

      x = np.linspace(_arg2 - 3*_arg3, _arg2 + 3*_arg3, 100)

       

       

      ", FLOAT([Variance]), FLOAT([Mean]), FLOAT([Std Dev]) )

       

      Will it be possible to help me make the graph?

       

      I have made the histogram using Tableau bins but I need to make the curve using Python.