This is an automated email from the ASF dual-hosted git repository.

asf-gitbox-commits pushed a commit to branch openformula
in repository https://gitbox.apache.org/repos/asf/openoffice.git

commit 079715a405d0849dd85aa890aa7f7bf19652a034
Author: Pedro Giffuni <[email protected]>
AuthorDate: Wed Nov 11 02:33:42 2026 -0500

    sc: implement SKEWP function (Milestone B)
    
    Add OpenFormula SKEWP (population skewness) reusing CalculateSkew()
    data collection from SKEW, with population standard deviation (denom N).
    
    - Implement ScInterpreter::ScSkewP() in interpr3.cxx:
      mean = sum/N; sigma = sqrt(sum((xi-mean)^2)/N);
      result = (1/N) * sum(((xi-mean)/sigma)^3)
    - Zero variance (including N=1) returns PushIllegalArgument
    - Declare ScSkewP() in interpre.hxx (committed with IFNA)
    - Add dispatch case ocSkewp in interpr4.cxx (committed with IFNA)
    - Add SKEWP name mappings in core_resource.src (committed with IFNA)
    - Add SKEWP regression tests to calcval-cases14.tsv (committed with IFNA)
    
    Build/test could not be executed (no configured AOO build tree).
---
 main/sc/source/core/tool/interpr3.cxx | 41 +++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/main/sc/source/core/tool/interpr3.cxx 
b/main/sc/source/core/tool/interpr3.cxx
index 74f60fb7b9..15c320718f 100644
--- a/main/sc/source/core/tool/interpr3.cxx
+++ b/main/sc/source/core/tool/interpr3.cxx
@@ -3103,6 +3103,47 @@ void ScInterpreter::ScSkew()
     PushDouble(((xcube * fCount) / (fCount - 1.0)) / (fCount - 2.0));
 }
 
+void ScInterpreter::ScSkewP()
+{
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::ScSkewP" 
);
+    double fSum,fCount,vSum;
+    std::vector<double> values;
+    if ( !CalculateSkew(fSum,fCount,vSum,values) )
+        return;
+
+    // Population skewness requires at least one numeric observation.
+    if (fCount < 1.0)
+    {
+        PushIllegalArgument();
+        return;
+    }
+
+    double fMean = fSum / fCount;
+
+    for (size_t i = 0; i < values.size(); i++)
+        vSum += (values[i] - fMean) * (values[i] - fMean);
+
+    // Population standard deviation: sigma = sqrt( sum((xi-mean)^2) / N )
+    double fSigma = sqrt(vSum / fCount);
+
+    // Zero variance (including a single observation) is undefined.
+    if (fSigma == 0.0)
+    {
+        PushIllegalArgument();
+        return;
+    }
+
+    double xcube = 0.0;
+    for (size_t i = 0; i < values.size(); i++)
+    {
+        double dx = (values[i] - fMean) / fSigma;
+        xcube = xcube + (dx * dx * dx);
+    }
+
+    // Population skewness: (1/N) * sum( ((xi-mean)/sigma)^3 )
+    PushDouble(xcube / fCount);
+}
+
 double ScInterpreter::GetMedian( vector<double> & rArray )
 {
     size_t nSize = rArray.size();

Reply via email to