cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X

Perform Statistical Calculations with Descriptive Analytics Part 2

No ratings

 

Step 5: Format Timed Values

 

At the top, click the Services section of scts_thing.

 

In the Ihnerited Services section, you will see the built-in services of the Statistical Calculation Thing Shape. These services can perform a variety of analytical calculations.

 

Timed Values Service

 

The Statistical Calculation Thing Shape can only perform analytics operations on time-series datasets. However, accessing a time-series Value Stream can have a performance hit on the system.

 

Instead, a Property with an Info Table using a timestamp/value Data Shape is used as the universal input to each built-in service of the Statistical Calculation Thing Shape.

 

For efficiency, we only reference the Value Stream once to create a formatted timedValues that is used as an input to all other service calls.

 

  1. At the top, click Services.

    25-scda-services.png

     

  2. Click + Add.

    26-scda-services-add.png

     

  3. In the Name field, enter timed_values_service.
  4. In the Javascript field, copy and past the following code:

     me.timed_values = me.QueryTimedValuesForProperty({
         propertyName: "numbers",
         maxItems: 10,
         startTime: me.start_time,
         endTime: me.end_time
     });
    27-scda-timed-values-service.png

     

  5. At the bottom, click Save and Execute.

    28-scda-save-execute.png

     

  6. Click Done, and return to Properties and Alerts.
  7. On the timed_values property row, click the pencil icon for Set value of property.

    29-scda-timed-values-pencil.png

     

  8. In the pop-up, note that there are now seven entries - each with the 1, 5, 9, 5, 9, 1, and 9 values and the timestamps when you entered them.

    34_scts_timed_vals_show.png

     

  9. In the pop-up, click Cancel.
  10. If needed, in the top-right, click the icon to close the slide-out.

 

Step 6: Calculation Services

 

Now that the numbers, start_time, end_time, and timed_values service inputs have been set, you can use the built-in Services of the Statistical Calculation Thing Shape to perform a variety of analytics calculations.

 

Mean Service

 

First, you will utilize the built-in CalculateMeanValue service.

 

The dataset is the following: 1, 5, 9, 5, 9, 1, 9.

 

As such, the mean should be (1+5+9+5+9+1+9)/7 = 39/7 = 5.571...

 

  1. Return to the Services section.
  2. At the top, click + Add.
  3. In the Name field, enter mean_service.
  4. In the Javascript code section, copy and paste the following:

     me.mean_result =  me.CalculateMeanValue({
         timedValues: me.timed_values
     });
  5. At the top, click Save and Continue.

    30-scda-mean-service.png

     

  6. At the bottom, click Execute.
  7. Click Done, then return to the Properties and Alerts section.
  8. Note that the mean_result property now has the value 5.571....
     

    31-scda-mean-result.png

 

Median Service

 

Next, you will utilize the built-in CalculateMedianValue service.

 

With our dataset having 5 as the middle value, that should be the result.

 

  1. Return to the Services section.
  2. At the top, click + Add.
  3. In the Name field, enter median_service.
  4. In the Javascript code section, copy and paste the following:

     me.median_result =  me.CalculateMedianValue({
         timedValues: me.timed_values
     });
  5. At the top, click Save and Continue.

    33-scda-median-service.png

    33-scda-median-service.png

  6. At the bottom, click Execute.
  7. Click Done, and return to the Properties and Alerts section.
  8. Note that the median_result Property now has the value 5.
     

    32-scda-medium-result.png

 

Mode Service

 

You will now utilize the built-in CalculateModeValue service.

 

With the dataset having 9 as the most common value, that should be the result.

 

  1. Return to the Services section.
  2. At the top, click + Add.
  3. In the Name field, enter mode_service.
  4. In the Javascript code section, copy and paste the following:

     me.mode_result =  me.CalculateModeValue({
         timedValues: me.timed_values
     });
  5. At the top, click Save and Continue.

     

    34-scda-mode-service.png

  6. At the bottom, click Execute.
  7. Click Done, and return to the Properties and Alerts section.
  8. On the mode_result row and under the Value column, click the "pencil" icon for Set value of property.
     

    35-scda-mode-pencil.png

  9. In the popup, note that the mode_result Property now has the value 9.
     

    43_scts_mode_result_popup.png

  10. Click Cancel to close the popup.
  11. If necessary, at the top-right, click the button to close the slide-out.

 

Standard Deviation Service

 

Lastly, you will utilize the built-in CalculateStandardDeviationValue service.

 

There are multiple free Standard Deviation calculators to check the answer.

 

Accordingly, the Standard Deviation should be 3.59894...

 

  1. Return to the Service section.
  2. At the top, click + Add.
  3. In the Name field, enter standarddev_service.
  4. In the Javascript code section, copy and paste the following:

     me.standarddev_result =  me.CalculateStandardDeviationValue({
         timedValues: me.timed_values
     });
  5. At the top, click Save and Continue.

     

    36-standard-dev-service.png

  6. At the bottom, click Execute.
  7. Click Done, and return to the Properties and Alerts section.
  8. Note that the standarddev_result property now has the value 3.59894...

     

37-scda-standard-dev-result.png
 
 

Step 7: Other Options

 

The Mean, Median, Mode, and Standard Deviation services you have completed are just a sampling of what the Statistical Calculation Thing Shape offers.

 

Below is a table of additional built-in services:

 

CalculationService NameDescription
Binned Data Distribution for Bin SizeCalculateBinnedDataDistributionForBinSizeCalculate the binned distribution of data points based on the desired bin size.
Binned Data Distribution for Number of BinsCalculateBinnedDataDistributionForNumberOfBinsCalculate the binned distribution of data points based on the desired number of bins.
Confidence Interval ValuesCalculateConfidenceIntervalValuesConfidence Interval Values Based on a specified confidence interval percentage, calculate the minimum, median, and maximum interval values.
Five Number Property ValuesCalculateFiveNumberPropertyValuesCalculate the five number values: minimum, lower quartile, median, upper quartile, and maximum.
Fourier TransformCalculateFourierTransformCalculate the results of running the fast Fourier transform on the specified values.
Maximum ValueCalculateMaximumValueCalculate the maximum property value in the provided infotable.
Minimum ValueCalculateMinimumValueCalculate the minimum property value in the provided infotable.
Sampling Frequency ValuesCalculateSamplingFrequencyValuesCalculate the sampling frequency values: minimum, median, and maximum.
 
 

Step 8: Next Steps

 

Congratulations!

 

In this guide, you have learned how to:

 

  • Create a Value Stream and Data Shape
  • Create a Thing with the Statistical Calculation Thing Shape
  • Modify a property to record values to the Value Stream
  • Utilize various built-in services for analytical calculations

 

Learn More

 

We recommend the following resources to continue your learning experience:

 

CapabilityGuide
BuildBuild a Predictive Analytics Model
BuildOperationalize an Analytics Model

 

Additional Resources

 

If you have questions, issues, or need additional information, refer to:

 

ResourceLink
CommunityDeveloper Community Forum
SupportDescriptive Analytics Help Center
Version history
Last update:
‎Nov 01, 2022 04:50 PM
Updated by:
Labels (2)
Contributors