-
Notifications
You must be signed in to change notification settings - Fork 57
$.predict()
Arthur Guiot edited this page Jul 13, 2017
·
2 revisions
This function is by far the COOLEST 😎 function in DisplayJS (but not the most useful. This price 🥇 is given to the $.var()
function 😊) because it can predict any point from 2 to 3 points. Let me explain, imagine you have a list of 3 number [3, 7, 11]
. From that we are going to generate a list of points, like that:
- The first point will be
[1, 3]
because 3 is the first item of our list - The second point will be
[2, 7]
because 7 is the second item of our list - The third point will be
[3, 11]
because 11 is the third item of our list
So, our list will contain each point, like that: [[1,3],[2,7],[3,11]]
.
Now, using the predict function, we can do 2 things:
- predict the
y
value for anyx
value. - Know the affine transformation that will give any number. (optional)
This function will take 3 arguments:
-
array
, the array of points. The minimum of points is 2, the third point is optional and is only here to check the model -
val
, this is thex
value, and it will return they
value (if the third argument is set to false 😉) -
text
, (true
orfalse
, by default its value isfalse
) Do you want to display the function and the result or only the result.
Now, let's predict the fourth value of our initial list.
JS:
// list of points fourth number
$.predict([[1,3],[2,7],[3,11]], 4) // 15
// list of points fourth number text will be displayed
$.predict([[1,3],[2,7],[3,11]], 4, true) // f(x) = 4x+-1; f(4) = 15
Don't hesitate to ask your questions
- Home
- The Core Languages
- Getting Started: Installation
- The Basics (
$.var()
+$.target()
) - Developing for DisplayJS
-
$.select()
- Text related
- If...else
$.xss()
$.repeat()
$.custom()
$.live()
$.load()
$.on()
$.onEvent()
$.ready()
- Scroll API
$.all()
$.clone()
$.is()
$.valEmpty()
$.remove()
$.show()
&$.hide()
$.ajax()
- Class Related
$.css()
$.getStyle()
- Fade effects
$.extend()
$.dynamic()
$.parent()
- Elements-Nodes
$.component()
$.time_ago()
$.copy()
$.then()
$.sleep()
$.getProp()