Skip to main content
1-Visitor
March 15, 2021
Question

Custom logic required for Mean, Median , Mode and Standard Deviation

  • March 15, 2021
  • 2 replies
  • 1937 views

Hi Team,

 

Suppose we don't want to install the analytics on our server and want to write custom logic for mean , median , mode and standard deviation calculation on our Thingworx 9.1 portal itself..

 

Could you please help with the custom logic for all these so that we would become dependency free from analytics.

 

Thanks in advance.

2 replies

5-Regular Member
March 15, 2021

I remember finding Mean, Median and Mode in a live data stream or data chuck is usually the interview question for CS students.  OOTB TWX side does not contain these functions, so apart from Platform analytics, you may need to write your own services in Extension (Resources-java) or custom scripts (javascript)

ranjank1-VisitorAuthor
1-Visitor
March 15, 2021

@zyuan1 

 

Please help in writing the custom logic in Javascript for dynamic size mean , median, mode and sd in thingworx itself.

5-Regular Member
March 16, 2021

The platform analytics is created for a reason.

 

1. The resource/ microservice size itself is in MB, and TWX script cannot handle very complex commands; 

2. the microservices is running independtly from the TWX server, since the infotable operation in TWX is costly and slow, and it will take away resources from other production services

 

You may try to migrate the sample codes online to TWX for a try

https://stackoverflow.com/questions/45309447/calculating-median-javascript 

Community Manager
March 29, 2021

Hi @ranjank.

 

If you feel your question has been answered, please mark the appropriate response as the Accepted Solution for the benefit of others with the same question.

 

Regards.

 

--Sharon