Calculator using python math functions


(Allen S. Harvey Jr.) #1

I need to calculate a new variable in my dataset, but I need access to math functions that aren’t available in the calculator filter. Specifically, I want to use the python math.erf function. Is there any way I can access this?


(Mathieu Westphal) #2

Calculator is not compatible with python. You want to use Python Calculator filter.


(Allen S. Harvey Jr.) #3

Well yes, but how can I access other functions in the python calculator? I’m thinking I need something like an “import math” command, but I don’t know how to do that in that filter. I know I can load libraries with programmable filter, but I don’t know how to setup a new variable using it.


(Mathieu Westphal) #4

You have access to the following methods :

As well as all numpy using np.

sadly this does not contain erf, nor math.

I suppose this importing math (and scipy) should be a good idea.


(Allen S. Harvey Jr.) #5

I was able to get done what I wanted through the programmable filter. That allowed me to import math, which gave me access to math.erf, which in turn allowed me to define a lognormal CDF (my real end goal). If in the future math and scipy.stats to the python calculator can be added, that would be great!