03-26-2019 11:08
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

03-26-2019 11:08
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
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
- ? at app/index.js:3,7
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.

Accepted Solutions
03-26-2019 14:51
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


03-26-2019 14:51
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
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/

03-26-2019 14:51
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


03-26-2019 14:51
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
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/

