Hi @sammy
From what I can tell I do not think we have any transformer that currently calculates Cumulative Normal Distribution, but this could be an interesting feature to post to the Ideas page if it gains enough support the dev team may add it to future versions of FME.
Let us know if you are successful using the PythonCaller method.
Thanks, Daragh
I was able to do the calculations using a PythonCaller transformer and the python norm.cdf() function from scipy stats.
I wanted to calculate the Standard Cumulative Normal Distribution (i.e. the Cumulative Normal Distribution with mean = 0 and standard deviation = 1) so I only had to input my value that I wanted the function calculated for. I did not need to specify the mean or the standard deviation.
More info if you need to specify the mean or standard deviation can be found here:
https://stackoverflow.com/questions/809362/how-to-calculate-cumulative-normal-distribution
Here are the details about the workflow -
ExcelReader:
- Pulling from an Excel sheet with sample data in a column called "input"
PythonCaller:
- Left the "Class or Funtion to Process Features" as the default "processFeature" - if you change this you will need to change it on line 5 in the python script below.
- Used norm.cdf() and selected "input" from FME Feature Attributes (to run the calculation my values from the Excel sheet).
- Assigned the calculated value to a new attribute called "result"
- Included "result" in Output Attributes, Attributes to Expose (so that I can use it for further calculations and/or output it).
- Script for the PythonCaller:
import fme
import fmeobjects
from scipy.stats import norm
def processFeature(feature):
result = norm.cdf(feature.getAttribute('input'))
feature.setAttribute("result", result)
pass
Python Compatibility:
- In the Navigator window -> Workspace Parameters -> Scripting ->Python Compatibility; Double click and change to match the python version installed on your computer.
Before I ran the workflow I had to install scipy into this folder (with my username and python version number e.g. python 3.7 would be python37) - C:\Users\<username>\Documents\FME\Plugins\Python\python<major><minor>
More instructions here:
https://docs.safe.com/fme/html/FME_Desktop_Documentation/FME_Workbench/Workbench/Installing-Python-Packages.htm