How to access value of integral with JSXGraph? - integral

I was reading: how to make a dynamic function to draw integral Graph from user input with JSXGraph?
There the value of the integral is "-1.6667". How to access the value?
I have tried to search help, but cannot find.

Solved:
function g(x){return Math.sin(x)+1};
var F = brd.create('point', [
function(){return s.X();},
function(){return JXG.Math.Numerics.I([-2,s.X()],g);}
],{});

Related

Google Sheet ImportXml converts value of numbers wrong

I'm trying to get coordinates from geonames api by importXml google sheet function. When I try this formula: IMPORTXML(G2;"//lat") where G2 is the api.
I get 4.747.104,00 but the actual value would be 47.47104. As the values are different I can not only solve that by *10 or similar.
To be honest, it was a mystery to me why the Germal locale reads the number 47.47104 as 4.747.104. But you can get over this problem by using one custom function instead of three ImportXml functions
function parseXml(url) {
let xml = UrlFetchApp.fetch(url).getContentText(),
document = XmlService.parse(xml),
root = document.getRootElement();
return [[root.getChild('name').getText(),root.getChild('lat').getText(),root.getChild('lng').getText()]]
}

Return True if Array Contains a Specific String - JSONata

Is there a way in JSONata to have a function return TRUE if it finds a specific string within a provided array? For example I have an array of colors:
const myArray = [red,blue,green,pink]
I am trying to figure out an expression that would search that array for "blue" and return true if it finds the value.
On the JSONata documentation, I found a function called $boolean(arg)that I think I would need to use but I'm not sure how to implement it. The documentation shows an argument type option as "array: contains a member that casts to true", but I can't really tell how to implement it.
Would it be as simple as $boolean(myArray, "blue")?
The in operator is what you need. See https://docs.jsonata.org/comparison-operators#in-inclusion
In your case, the expression "blue" in myArray will return true. See https://try.jsonata.org/r0q7GnSOh
edit: Thought this was python, but maybe you could use something similar for JSONata
you can make a for loop with an if condition to check your condition
listOfStrings = ['red','green','blue']
for strings in listOfStrings:
if listOfStrings[strings] == 'blue':
return True

how to add threshhold value in the QnA maker if it being called using the QnAMakerRecognizer.recognize method

I replaced my code where I was making a QnA dialog using new cognitiveservices.QnAMakerDialog constructor and I was able to pass extra key-value pair for example threshold, feedbackLib etc. with the code where I can use QnA in single dialog using
cognitiveservices.QnAMakerRecognizer.recognize(query, 'QnAhost', 'endpointKey key','Authorization', 3, 'intentname', function (error, results) 
{
session.send(results.answers[0].answer); 
// console.log(results);
}); 
}).triggerAction({
matches: 'intentname'
});
But I am not sure how can I add the threshold value and feedbackLib to the QnA. This way it is returning an answer even if the confidence score is very low.
Please help.
Thanks.
Vivek,
the constructor for QnAMakerRecognizer takes a set of IQnAMakerOptions. These are defined here
When you create your recognizer instance call the contructor like this:
var recognizer = new cognitiveservices.QnAMakerRecognizer({
knowledgeBaseId: 'set your kbid here',
authKey: 'set your authorization key here',
qnaThreshold: (This is a number) set your threshold value here,
feedbackLib: (This is a QnAMakerTool object) set your lib here
});
Hope this helps.

Need to calculate length in km of line in RethinkDB

I have a Line object in a document inside RethinkDB
I am looking for an easy/efficient way of calculating the real world distance of the line.
My initial strategy was to pull the line out of the database and calculate it inside Node.js but ideally would like a way to do this 'in the box'
I cannot find a way to iterate over the coordinates of the line inside ReQl and use the distance function to calculate.
Any help is greatly appreciated.
Unfortunately, the only way I could find how to do this, as it seems that the points within the r.line object are inaccessible, is to convert the line into GeoJSON, convert to points, and then return the calculation.
Using an object like this:
{
id: 101,
route: r.line([-122.423246,37.779388], [-121.886420,37.329898])
}
Your query would look like this:
r.table('data').get(101)('route').do(function(doc){
var points = doc.toGeojson()("coordinates").map(function(point){
return r.point(point(0), point(1));
});
return {
"distance": points(0).distance(points(1))
}
});
Or, as you probably have a whole bunch of line distances to calculate:
r.table('data').hasFields("route")('route').map(function(doc){
var points = doc.toGeojson()("coordinates").map(function(point){
return r.point(point(0), point(1));
});
return {
line: points(0).distance(points(1))
}
});
I've also submitted a Github issue to see if we can find an improvement!

Time scale won't convert dates to numbers

I am having trouble with using the time scale. I have dates in the format 'YYYYMMDD', I parse these with:
parseDate = d3.time.format("%Y%m%d").parse
I set the domain to static dates using the same above function. I can see the dates in correct format in the console. But when applying the scale function x, it returns 'NaN' WAT?
It's probably something small I'm not seeing, it's driving me mad...
Code can be found here: http://bl.ocks.org/pberden/5668581
I think the problem is in the way you call d3.nest. According to the spec
The key function will be invoked for each element in the input array, and must return a string identifier that is used to assign the element to its group.
You convert the Day in your csv file to a Date but then, as you are building a map from the array using d3.nest(), the invocation of the key function turns this Date to a String by doing an implicit conversion.
To fix this I think you could try to force your line generator to turn a String into Date like so
var line = d3.svg.line()
.x(function(d) { return x(new Date(d.key)); })
.y(function(d) { return y(d.values.Value); });

Resources