I realized that this is outside of the Salesforce wheelhouse, but can anyone help?

I have a custom class that determines the t-static from a series of pairwise tests. I have a requirement to calculate the p-value for the particular t-statistic and degrees of freedom.

I am looking for a function similar to the Math3.TTest (http://commons.apache.org/proper/commons-math/javadocs/api-3.4/org/apache/commons/math3/stat/inference/TTest.html) function in Java. Is anyone familiar with a similar function in Apex or do they know of how to write one without an established Continuous Distribution Function?

  • Could you do a callout to a heroku web service or other server, running a language which has these functions? Commented Jan 26, 2018 at 1:40
  • I could have. I was looking for a more lightweight solution than running an servlet to handle a single calculation. In the end, the customer relented that it didn't need to be calculated in real-time. As a result, I wrote a quick python script to query the records that had data ready to calculate a p-value and do that with a stats library in Python.
    – RD3
    Commented Feb 20, 2018 at 2:52

1 Answer 1


As of 20190322 there is no native Salesforce solution for this problem.

There were three solutions we evaluated. 1) A call out to a servlet to run the calculation. 2) A REST API call using Simple-Salesforce and the Python library to do the calculation. 3) Dataloader Extract and run through Excel to calculate the value.

We opted for Option 2 since we already had a suite of utilities built on Python and it was easy to add a new function.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .