03-26-2019 11:08
03-26-2019 11:08
Hello! I was trying to use Scientific API for my final thesis but I found this problem using the provided code in the developer module: https://dev.fitbit.com/build/reference/device-api/scientific/
import { scientific } from "scientific";
const arr = new Float32Array(1,2,3,4,5);
const mean = scientific.mean(arr);
const max = scientific.max(arr);
const min = scientific.min(arr);When I tried to run it in Fitbit Studio it showed the following error:
Unhandled exception: TypeError: Cannot read property 'mean' of undefined
I checked in package.json which SDK version it's using and it's 3.1 so Scientific API should work. Probably it's an error caused by the type of the array given, but in de module said that it works with Float32Array.
Could anyone tell me how to use the Scientific API properly? Thank you.
Answered! Go to the Best Answer.
Best Answer03-26-2019 14:51
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
03-26-2019 14:51
Sorry, looks like a few issues with that example. I'll ensure the site gets updated.
Here's a working snippet:
import * as scientific from "scientific"
const X = new Float32Array([1,2,3,4,5]);
console.log(`Sum=${scientific.sum(X)}`)
console.log(`Mean=${scientific.mean(X)}`)
console.log(`Max=${scientific.max(X)}`)
console.log(`Min=${scientific.min(X)}`)
You can also checkout the API in action here: https://github.com/Fitbit/sdk-scientific/
Best Answer03-26-2019 14:51
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
03-26-2019 14:51
Sorry, looks like a few issues with that example. I'll ensure the site gets updated.
Here's a working snippet:
import * as scientific from "scientific"
const X = new Float32Array([1,2,3,4,5]);
console.log(`Sum=${scientific.sum(X)}`)
console.log(`Mean=${scientific.mean(X)}`)
console.log(`Max=${scientific.max(X)}`)
console.log(`Min=${scientific.min(X)}`)
You can also checkout the API in action here: https://github.com/Fitbit/sdk-scientific/
Best Answer