Bug in Graphs - creating a ChartData by adding points prints an error message

Hi,

I am a computer sciences teacher. Two of my students created an app for drawing graphs and ran across the following bug: when you create a ChartData by adding points and you try to plot a Quadratic graph, you get the following error message (although the graph is plotter OK) :

org.apache.commons.math3.exception.MathIllegalArgumentException: not enough data (3 rows) for this many predictors (3 predictors) at org.apache.commons.math3.stat.regression.AbstractMultipleLinearRegression.validateSampleData(AbstractMultipleLinearRegression.java:235) at org.apache.commons.math3.stat.regression.OLSMultipleLinearRegression.newSampleData(OLSMultipleLinearRegression.java:90) at com.google.appinventor.components.runtime.util.OlsTrendLine.compute(OlsTrendLine.java:90) at com.google.appinventor.components.runtime.util.QuadraticRegression.compute(QuadraticRegression.java:34) at com.google.appinventor.components.runtime.Trendline.onDataSourceValueChange(Trendline.java:186) at com.google.appinventor.components.runtime.ChartDataBase.onDataChange(ChartDataBase.java:274) at com.google.appinventor.components.runtime.ChartData2D$1.run(ChartData2D.java:84) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1154) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:652) at java.lang.Thread.run(Thread.java:1564)
Note: You will not see another error reported for 5 seconds.

I am attaching an AIA file of a project I created that demonstrates the problem (I left only the relevant parts).
A workaround to solve this is by creating a list in the same format that ChartData represents, and importing it (this is the variable YYDebug in the code), but still the bug in adding points exists and should be addressed.
Thank you!
Yossi Yaron

Graphs_TR.aia (3.5 KB)

The Trendline component looks fragile, and is not reporting its lack of data nicely.

Here is a work around to save setting the Trendline model at start and end of data collection, starting with the simplest (linear) and least demanding model, and ending with more demanding model (quadratic.)


(draggable)

This is due to the fact you have a quadratic trend line associated to the chart.

You need a minimum number of point to calculate the quadratic trend ( 4 points if I’m not wrong ).

So you can add the points all at one as you said or “disconnect” the trend line after clean and “reconnect” after points added

1 Like

This is clearly a regression calculation issue.

The developer of that facility failed to allow for a graceful error message to report insufficient data points to support quadratic curve fitting.

What is your experience level with quadratic curve fitting techniques?