SED navigation bar go to SED home page go to Dataplot home page go to NIST home page SED Home Page SED Staff SED Projects SED Products and Publications Search SED Pages
Dataplot Vol 1 Vol 2

STATISTIC BLOCK

Name:
    STATISTIC BLOCK
Type:
    Analysis Command
Purpose:
    Defines a statistic via a group of Dataplot commands.
Description:
    Dataplot supports a large number of built-in statistics (enter HELP STATISTICS for a complete list). For example,

      LET A = MEAN Y
      LET A = STANDARD DEVIATION Y
      LET A = CORRELATION Y1 Y2

    Built-in statistics can be used in the following commands

    1. LET A = <stat>
    2. <stat> STATISTIC PLOT
    3. CROSS TABULATE <stat> STATISTIC PLOT
    4. FLUCTUATION PLOT <stat>
    5. <stat> BLOCK PLOT
    6. BOOTSTRAP <STAT> PLOT
    7. JACKNIFE <stat> PLOT
    8. DEX <STAT> PLOT
    9. <stat> INFLUENCE CURVE
    10. CROSS TABULATE <stat>
    11. POSITIONAL TABULATION <stat>
    12. LET V = MATRIX COLUMN <stat>
    13. LET V = MATRIX ROW <stat>
    14. LET A = MATRIX GRAND <stat>
    15. LET M = MATRIX PARTITION <stat>
    16. LET V = CROSS TABULATE <stat>
    17. LET V = CROSS TABULATE CUMULATIVE <stat>
    18. LET V = SORT BY <stat>
    19. LET YOUT = MOVING <stat>
    20. LET YOUT = CUMULATIVE <stat>
    21. <stat> INTERACTION PLOT

    Although Dataplot provides a large number of built-in statistics, there may be situations where you would like to define a statistic not already supported by Dataplot. Statistic blocks were introduced to address this limitation. Statistic blocks allow you to define statistics using various Dataplot LET subcommands.

    Statistic blocks are created using the CAPTURE syntax. For example,

      CAPTURE STATISTIC BLOCK ONE ZZZZMEAN A Y
      LET N = SIZE Y
      LET YSUM = SUM Y
      LET A = YSUM/N
      END OF CAPTURE

    The statistic block contains the following components

    1. CAPTURE STATISTIC BLOCK - this initiates the creation of the statistic block. The CAPTURE command is typically used to direct Dataplot output to a file. However, in this case it saves the specified commands in an internal structure that can be accessed later.

    2. ONE - up to three statistic blocks can be defined. In this example, "ONE" specifies that this is statistic block one. You can redefine these three statistic blocks as often as you need in a Dataplot session.

    3. ZZZZMEAN - this is the name of the statistic block. This is the name that will be used to execute the statistic block in subsequent commands. This follows the rules for other Dataplot names (i.e., up to eight alphanumeric characters).

      Note that this name should not be the same as one of Dataplot's built-in statistics.

    4. A - this is name of the parameter that will contain the response for the statistic block. This is the value that is typically defined in the last line of the statistic block. For statistic blocks, the response must be a parameter. If the response is a variable, an error will be returned.

    5. Y - this is the response variable for which the statistic is being computed. You can specify from one to three response variables.

    The following Dataplot commands can be included in a statistic block:

    1. LET ... = PATTERN ...
    2. LET ... = DATA ...
    3. LET ... = ... RANDOM NUMBERS ...
    4. ARITHMETIC OPERATIONS
    5. STATISTIC LET SUB-COMMANDS
    6. MATH LET SUB-COMMANDS

      The following MATH LET sub-commands are not allowed:

      • MATRIX sub-commands
      • DERIVATIVE
      • NUMERICAL DERIVATIVE
      • INTEGRAL
      • RUNGE-KUTTA
      • OPTIMIZE
      • ROOTS

    The arithmetic operations and statistics LET sub-commands are of particular interest. Commands that are not supported are not added to the statistic block during the CAPTURE operation. Up to 30 commands can be saved to a given statistic block.

Syntax 1:
    CAPTURE STATISTIC BLOCK <one/two/three> <name> <resp> <variable list>
    where <one/two/three> specifies which statistic block is being created;
                <name> is the name of the statistic block;
                <resp> is the name of parameter that is the result of the statistic block;
                and where <variable list> is a list of 1 to 3 variable names that are used to compute the statistic.

    This syntax is used to create the contents of a statistic block.

Syntax 2:
    LIST STATISTIC BLOCK <one/two/three>
    where <one/two/three> specifies which statistic block is being listed.

    This syntax is used to list the contents of a statistic block.

Examples:
    capture statistic block one zzzzsd a y
    let n = size y
    let ysum = sum y
    let ymean = ysum/n
    let y2 = (y - ymean)**2
    let y2sum = sum y2
    let a = sqrt(y2sum/(n-1))
    end of capture
Note:
    Error checking (e.g., matching parenthesis, valid number of arguments for a built-in function) is performed when the statistic block is evaluated, not when it is created.
Note:
    There may be cases where you cannot create the needed statistic even with the STATISTIC BLOCK command. The LET ... = EXECUTE ... command can be used to run an external prorgram. That is, your statistic block can use the EXECUTE command to compute the desired statistic. You can create the external program in whatever language is most convenient for your application. The basic requirement is that the resulting external file can be run from the command line and that it can read from standard input and write to standard output.

    This is demonstrated in the Program 2 example below.

Default:
    None
Synonyms:
    None
Related Commands:
    LET = Carries out a variety of operations on variables, parameters, and functions.
    LET FUNCTION = Define a function.
    FUNCTION BLOCK = Define a function block.
    EXECUTE = Run an external program.
    CAPTURE = Direct Dataplot output to an external file.
Applications:
    Statistics
Implementation Date:
    2016/08
Program 1:
     
    skip 25
    read gear.dat y x
    skip 0
    .
    . Step 2:   Define the statistic block
    .
    capture statistic block one zzzzsd a y
    let n = size y
    let ysum = sum y
    let ymean = ysum/n
    let y2 = (y - ymean)**2
    let y2sum = sum y2
    let a = sqrt(y2sum/(n-1))
    end of capture
    .
    xlimits 1 10
    major xtic mark number 10
    x1tic mark offset 0.5 0.5
    x1label Batch
    y1label SD of Batch
    line blank
    char X
    .
    multiplot corner coordinates 2 2 98 98
    multiplot scale factor 2
    multiplot 2 1
    title automatic
    .
    zzzzsd plot y x
    sd     plot y x
    .
    end of multiplot
        
    plot generated by sample program
Program 2:
     
    . Step 1:   Read the data
    .  
    skip 25
    read gear.dat y x
    skip 0
    .
    . Step 2:   Create and compile the Fortran code
    .
    capture script exec.for
          program test
    c
    c     For this simple example, read in a data set and
    c     compute the mean and standard deviation.
    c
          real x(10000)
    c
          xmean=0.0
          xsd=0.0
          nval=0
          read(*,*,end=19,err=9020)nval
    c
          sum1=0.0
          do 10 i=1,min(nval,10000)
             read(*,*,end=19,err=9020)x(i)
             sum1=sum1 + x(i)
       10 continue
       19 continue
          if(nval.ge.1)then
            xmean=sum1/real(nval)
          endif
    c
          if(nval.gt.1)then
            sum1=0.0
            do 20 i=1,nval
               sum1=sum1 + (x(i)-xmean)**2
      20    continue
            xsd=sqrt(sum1/real(nval-1))
          endif
    c
    c     Now write sd to standard output
    c
     9020 continue
          write(*,*)xsd
    c
          stop
          end
    end of capture
    .
    system gfortran -o exec.exe  exec.for
    .
    . Step 3:   Define the statistic block
    .
    capture statistic block one zzzzsd a y
    let ztemp = execute ./exec.exe y
    let a = ztemp(1)
    end of capture
    .
    xlimits 1 10
    major xtic mark number 10
    x1tic mark offset 0.5 0.5
    x1label Batch
    y1label SD of Batch
    line blank
    char X
    .
    multiplot corner coordinates 2 2 98 98
    multiplot scale factor 2
    multiplot 2 1
    title automatic
    .
    zzzzsd plot y x
    sd     plot y x
    .
    end of multiplot
        
    plot generated by sample program

Privacy Policy/Security Notice
Disclaimer | FOIA

NIST is an agency of the U.S. Commerce Department.

Date created: 09/23/2016
Last updated: 09/23/2016

Please email comments on this WWW page to alan.heckert.gov.