lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbern...@apache.org
Subject lucene-solr:master: SOLR-12634: Add gaussfit to the Math Expressions user guide
Date Tue, 28 Aug 2018 21:01:30 GMT
Repository: lucene-solr
Updated Branches:
  refs/heads/master 6430749d4 -> 1cfc735ff


SOLR-12634: Add gaussfit to the Math Expressions user guide


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/1cfc735f
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/1cfc735f
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/1cfc735f

Branch: refs/heads/master
Commit: 1cfc735fff05bd2287adb85a6c8ad28ed96926b7
Parents: 6430749
Author: Joel Bernstein <jbernste@apache.org>
Authored: Tue Aug 28 17:00:47 2018 -0400
Committer: Joel Bernstein <jbernste@apache.org>
Committed: Tue Aug 28 17:01:15 2018 -0400

----------------------------------------------------------------------
 solr/solr-ref-guide/src/curve-fitting.adoc | 148 +++++++++++++++++++++---
 1 file changed, 135 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/1cfc735f/solr/solr-ref-guide/src/curve-fitting.adoc
----------------------------------------------------------------------
diff --git a/solr/solr-ref-guide/src/curve-fitting.adoc b/solr/solr-ref-guide/src/curve-fitting.adoc
index 057cc23..336ffde 100644
--- a/solr/solr-ref-guide/src/curve-fitting.adoc
+++ b/solr/solr-ref-guide/src/curve-fitting.adoc
@@ -133,28 +133,106 @@ responds with:
 ----
 
 
-== Prediction, Derivatives and Integrals
+=== Prediction, Derivatives and Integrals
 
-The `polyfit` function returns an array which contains the *y* value data points
-of the fitted curve.
-
-In order to predict values along the curve an interpolation function must be created
-for the curve. Once an interpolation functin has been created the `predict`,
-`derivative` and `integral` functions can be applied to the curve.
+The `polyfit` function returns a function that can be used with the `predict`
+function.
 
 In the example below the x axis is included for clarity.
-The `polyfit` function returns an array with the fitted curve.
-A linear inpolation function is then created for the curve with the `lerp` function.
+The `polyfit` function returns a function for the fitted curve.
 The `predict` function is then used to predict a value along the curve, in this
-case the prediction is made for the *x* value of .5.
+case the prediction is made for the *x* value of 5.
 
 [source,text]
 ----
 let(x=array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14),
     y=array(0, 1, 2, 3, 4, 5.7, 6, 7, 6, 5, 5, 3, 2, 1, 0),
     curve=polyfit(x, y, 5),
-    interp=lerp(x, curve),
-    p=predict(interp, .5))
+    p=predict(curve, 5))
+----
+
+When this expression is sent to the /stream handler it
+responds with:
+
+[source,json]
+----
+{
+  "result-set": {
+    "docs": [
+      {
+        "p": 5.439695598519129
+      },
+      {
+        "EOF": true,
+        "RESPONSE_TIME": 0
+      }
+    ]
+  }
+}
+----
+
+The `derivative` and `integrate` functions can be used to compute the derivative
+and integrals for the fitted
+curve. The example below demonstrates how to compute a derivative
+for the fitted curve.
+
+
+[source,text]
+----
+let(x=array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14),
+    y=array(0, 1, 2, 3, 4, 5.7, 6, 7, 6, 5, 5, 3, 2, 1, 0),
+    curve=polyfit(x, y, 5),
+    d=derivative(curve))
+----
+
+When this expression is sent to the /stream handler it
+responds with:
+
+[source,json]
+----
+{
+  "result-set": {
+    "docs": [
+      {
+        "d": [
+          0.3198918573686361,
+          0.9261492094077225,
+          1.2374272373653175,
+          1.30051359631081,
+          1.1628032287629813,
+          0.8722983646900058,
+          0.47760852150945,
+          0.02795050408827482,
+          -0.42685159525716865,
+          -0.8363663967611356,
+          -1.1495552332084857,
+          -1.3147721499346892,
+          -1.2797639048258267,
+          -0.9916699683185771,
+          -0.3970225234002308
+        ]
+      },
+      {
+        "EOF": true,
+        "RESPONSE_TIME": 0
+      }
+    ]
+  }
+}
+----
+
+
+== Gaussian Curve Fitting
+
+The `gaussfit` function fits a smooth curve through a gaussian peak.
+This is shown in the example below.
+
+
+[source,text]
+----
+let(x=array(0,1,2,3,4,5,6,7,8,9, 10),
+    y=array(4,55,1200,3028,12000,18422,13328,6426,1696,239,20),
+    f=gaussfit(x, y))
 ----
 
 When this expression is sent to the /stream handler it
@@ -166,7 +244,19 @@ responds with:
   "result-set": {
     "docs": [
       {
-        "p": 0.4481424148606813
+        "f": [
+          2.81764431935644,
+          61.157417979413424,
+          684.2328985468831,
+          3945.9411154167447,
+          11729.758936952656,
+          17972.951897338007,
+          14195.201949425435,
+          5779.03836032222,
+          1212.7224502169634,
+          131.17742331530349,
+          7.3138931735866946
+        ]
       },
       {
         "EOF": true,
@@ -177,6 +267,38 @@ responds with:
 }
 ----
 
+Like the `polyfit` function, the `gaussfit` function returns a function that can
+be used directly by the `predict`, `derivative` and `integrate` functions.
+
+The example below demonstrates how to compute an integral for a
+fitted gaussian curve.
 
 
+[source,text]
+----
+let(x=array(0,1,2,3,4,5,6,7,8,9, 10),
+    y=array(4,55,1200,3028,12000,18422,13328,6426,1696,239,20),
+    f=gaussfit(x, y),
+    i=integrate(f, 0, 5))
 
+----
+
+When this expression is sent to the /stream handler it
+responds with:
+
+[source,json]
+----
+{
+  "result-set": {
+    "docs": [
+      {
+        "i": 25261.666789766092
+      },
+      {
+        "EOF": true,
+        "RESPONSE_TIME": 3
+      }
+    ]
+  }
+}
+----


Mime
View raw message