From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

percentiles & boxplots

Solved!
Go to solution

Hello, I have 2 questions:

 

1) is there a quick way to compute percentiles different from 25% (1st quartile), 50% (Median) and 75%(3rd quartile)? I notice that there is no possibility to choose the desired percentage in StatSel (StatBlockCalc) but maybe you can suggest me another function. In the opposite case, I will do it manually ordering the channel and choosing the X% value...

 

2) I read that boxplots are available in the 2019 beta version, no way to do them in 2015 version? Should I build them "manually" with lines and dots?

 

Thank you and kind regards,

Mattia

 

0 Kudos
Message 1 of 8
(2,962 Views)

Hello Mattia,

I’m sorry, boxplots are new in DIAdem 2019 and for tats we extended the calculations for percentiles (0.025 and 0.975). In former DIAdem versions you can only do this yourself (or upgrade to DIAdem 2019)

Greetings

Walter

0 Kudos
Message 2 of 8
(2,898 Views)
Solution
Accepted by topic author mattia_verona

I made a few "manual" box plots last year.  Attached is the data and the TDR for the report.  Run the following script on the data and refresh the report:  (or get DIAdem 2019!)

 

'-------------------------------------------------------------------------------
'-- VBS script file
'-- Created on 06/11/2018 10:57:21
'-- Comment: Box Plot
'-------------------------------------------------------------------------------
Option Explicit  'Forces the explicit declaration of all the variables in a script.

' EXAMPLE CALL
Call BoxPlotGroup(Data.Root.ChannelGroups("Data").Channels("RPM"), "Box Plot RPM", 1, 7, 4, 3, 5)
Call BoxPlotGroup(Data.Root.ChannelGroups("Data").Channels("Temperature"), "Box Plot Temp", 8, 14, 11, 10, 12)

' Create a plottable box-whisker channel group for a channel
' ARG 1: Input channel
' ARG 2: Output group name
' ARG 3: Numeric left boundary of the box
' ARG 4: Numeric left boundary of the box
' ARG 5: Numeric vertical middle of the box
' ARG 6: Numeric left of the whisker
' ARG 7: Numeric right of the whisker
' RETURN: Nothing. A group with the supplied name will be created
' NOTES: No error checking implemented (Ex, if you supply a channel of DataTypeChnString it will crash
Function BoxPlotGroup(chnl, boxGrpName, BoxLeft, BoxRight, BoxMid, WhiskLeft, WhiskRight)

  ' GET STATS
  Dim min, max, q1, med, q3
  Call ChnStatisticsChannelCalc(chnl.GetReference(eRefTypeIndexName), 3608, 0, 0, 1, 0, 0, "NameName")
  min = chnl.Properties("Result~Statistics~ExtremeValues~Minimum").Value
  max = chnl.Properties("Result~Statistics~ExtremeValues~Maximum").Value
  q1 = chnl.Properties("Result~Statistics~Quantiles~LowerQuartile").Value
  med = chnl.Properties("Result~Statistics~Quantiles~Median").Value
  q3 = chnl.Properties("Result~Statistics~Quantiles~UpperQuartile").Value
  
  ' CREATE RESULT GROUP
  Dim boxGrp, i
  Dim Names: Names = Array("Upper Whisk", "Lower Whisk", "Lower Box", "Upper Box", "Middle Box", "Left Box", "Right Box", "Lower Whisk Connect", "Upper Whisk Connect")
  Dim x: x = Array(WhiskLeft, WhiskLeft, BoxLeft, BoxLeft, BoxLeft, BoxLeft, BoxRight, BoxMid, BoxMid)
  Dim x2: x2 = Array(WhiskRight, WhiskRight, BoxRight, BoxRight, BoxRight, BoxLeft, BoxRight, BoxMid, BoxMid)
  Dim y: y = Array(max, min, q1, q3, med, q1, q1, q1, q3)
  Dim y2: y2 = Array(max, min, q1, q3, med, q3, q3, min, max)
  Call Data.Root.ChannelGroups.Add(boxGrpName)
  Set boxGrp = Data.Root.ChannelGroups(boxGrpName)
  Call boxGrp.Properties.Add("Channel", chnl.GetReference(eRefTypeNameName), DataTypeString)
  Call boxGrp.Properties.Add("Measurement", chnl.Name, DataTypeString)
  Call boxGrp.Properties.Add("SampleSize", chnl.Size, DataTypeFloat64)
  For i = 0 To UBound(x, 1) Step 1
    Call boxGrp.Channels.Add(Names(i) & " - x", DataTypeChnFloat64)
    Call boxGrp.Channels.Add(Names(i) & " - y", DataTypeChnFloat64)
    boxGrp.Channels(Names(i) & " - x").Values(1) = x(i)
    boxGrp.Channels(Names(i) & " - x").Values(2) = x2(i)
    boxGrp.Channels(Names(i) & " - y").Values(1) = y(i)
    boxGrp.Channels(Names(i) & " - y").Values(2) = y2(i)
  Next
  
End Function
0 Kudos
Message 3 of 8
(2,885 Views)

Hi gsklyr,

 

thank you, that is very useful! I don't find the .tdr, can you please check it? Possibly you forgot to attach it.

 

Mattia

0 Kudos
Message 4 of 8
(2,875 Views)
0 Kudos
Message 5 of 8
(2,861 Views)

Thank you!

 

Mattia

0 Kudos
Message 6 of 8
(2,844 Views)

Hi,

 

I am not able to see boxplot option in DIAdem 2019 plot. What could be the possible reason?

 

Thanks

Ashwini

0 Kudos
Message 7 of 8
(2,623 Views)

Hi Ashwini,

 

Box-Whisker plots are part of the 2D-axis definition.

P1.png

 

With the next DIAdem version, you will get an easier user interface for the REPORT objects.

 

Greetings

Walter

 

Message 8 of 8
(2,611 Views)