Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X
Use the statistical calculation Thing Shape to execute useful analysis services
This project will introduce the Statistical Monitoring Thing Shape.
This guide demonstrates using Descriptive Analytics from ThingWorx Predictive Analytics to perform common statistical monitoring analysis on time-series data. You will learn to use the Statistical Monitoring ThingShape's built-in services to return the number of values in a data set that are: above or below a threshold, inside or outside a defined range, or following a trend that is: increasing, decreasing, or alternating.
NOTE: The estimated time to complete this guide is 30 minutes.
Descriptive analytics lets you perform common statistical monitoring calculations on changes in a Property value over time.
Output from monitoring Services can be used in IoT applications built with ThingWorx to provide trend and numerical limits feedback.
This guide introduces the Statistical Monitoring Thing Shape which adds Services to Things and Thing Templates for reporting Property values that are: above or below a threshold, inside or outside a defined range, or following a trend that is: increasing, decreasing, or alternating.
These Services analyze time-series data which is stored in ThingWorx Foundation as changes to a Property value logged to a Value Stream.
To ensure optimum performance, both a time range and a maximum number of value changes must be specified.
Statistical monitoring Services operate on Property values that change over time. To create this time series data, Property value changes are logged in a Value Stream. In this step, you will create a Value Stream, then a Thing with a Property that logs changes to that Value Stream.
Follow the steps below to create a value stream which you will later tie to a Thing.
1. On the ThingWorx Composer Browse tab, click Data Storage > Value Streams, then click the +New button
2. Select ValueStream and click OK.
3. In the Name field, enter scts_valuestream.
4. If Project is not already set, click the + in the Project text box and select the PTCDefaultProject.
5. At the top, click Save.
Now, you will create a Thing with a property and configure it to use the previously-created value stream. You will also apply the statistical monitoring Thing Shape to the Thing, which makes the built-in analytics services available.
1. On the ThingWorx Composer Browse tab, click MODELING > Things then click the + New button
2. In the Name field, enter scts_thing.
3. If Project is not already set, click the + in the Project text box and select the PTCDefaultProject.
4. In the Base Thing Template field, search for and select GenericThing.
5. In the Implemented Shapes field, search for and select StatisticalMonitoringThingShape.
6. In the Value Stream field, search for and select scts_valuestream.
7. At the top, click Save.
You will now add a property to scts_thing.
1. At the top, click Properties and Alerts
2. Click + Add.
3. In the right slide-out's Name field, enter numbers.
4. Change the Base Type to NUMBER.
5. Click Persistent.
6. Click Logged.
7. Click Advanced Settings to open the bottom panel, in the Data Change Type drop-down select Always.
8. At the top-right, click the "check" icon for DONE.
9. At the top, click Save.
In this step, you will enter sample data that will illustrate the available Services.
This dataset: 2, 3, 4, 3, 2, 2, 1, 2, 1, 1, 2, 3, 3, 4, 3, 2 is shown graphed.
Perform the steps below to enter the above values into the Numbers Property.
1. Under the Value column and on the Numbers property row, click the "pencil" icon for Set value of property.
2. In the right-side slide-out, enter 2.
3. At the top-right, click the "check" icon for Done.
4. At the top, click Save.
5. Repeat steps 1-4 above, but changing the value each time as per the table below:
Value Change Count | Entered Value |
2nd | 3 |
3rd | 4 |
4th | 3 |
5th | 2 |
6th | 2 |
7th | 1 |
8th | 2 |
9th | 1 |
10th | 1 |
11th | 2 |
12th | 3 |
13th | 3 |
14th | 4 |
15th | 3 |
16th | 2 |
Now that value changes to the numbers Property have been logged in a Value Stream, you can use the built-in Services of the Statistical Monitoring Thing Shape to return how many of values meet different monitoring criteria.
You will test the built-in GetNumberOfConsecutivePointsFollowingATrend Service. This Service will return how many of points in the largest group of values following one of the three trend types INCREASING, DECREASING, and ALTERNATING.
1. Click the Service tab in the scts_thing Thing.
2. Click the GetNumberOfConsecutivePointsFollowingATrend Service.
3. In the PropertyName field enter numbers.
4. In the NumberOfPoints field enter 16 to check all entered points.
5. In the Trend field enter INCREASING to find the largest number of points with an increasing trend.
6. Click the green Execute button and note the Result property in the Output panel has the value 6
7. Repeat the steps above changing the Trend to DECREASING and note the result is 5.
We'll now test the built-in GetNumberOfPointsBasedOnARange Service. This Service will return the number of points INSIDE or OUTSIDE a range of values specified by a MIN and MAX value.
1. Click the Close button in the Services tab in the scts_thing Thing.
2. Click the GetNumberOfPointsBasedOnARange Service.
3. In the PropertyName field enter numbers.
4. In the NumberOfPoints field enter 16 to check all entered points.
5. In the Min field enter 1.5 to set the lower end of the range criteria.
6. In the Max field enter 2.5 to set the upper end of the range criteria.
7. In the RegionOfInterest field enter INSIDE to find the largest number of points with an increasing trend.
8. Keep the default IncludeMin and IncludeMax set to True.
9. Click the green Execute button and note the Result property in the Output panel has the value 6.
10. Repeat the steps above changing the RegionOfInterest to OUTSIDEand note the result is 10.
You will now test the built-in GetNumberOfPointsBeyondAThreshold Service. This Service will return the number of points ABOVE or BELOW a specified value.
1. Click the Services tab in the scts_thing Thing.
2. Click the GetNumberOfPointsBeyondAThreshold Service.
3. In the PropertyName field enter numbers.
4. In the NumberOfPoints field enter 16 to check all entered points.
5. In the Threshold field enter 3 to set the threshold criteria.
6. In the Direction field enter ABOVE to find the number of points above the threshold value.
7. Keep the default IncludeThreshold set to True.
8. Click the green Execute button and note the Result property in the Output panel has the value 7.
9. Repeat the steps above changing the Direction to BELOWand note the result is 14.
Click here to view Part 2 of this guide.