This is another one of those scrips that extends the flexibility of GrADS beyond it's intended purpose. As usual, these analyses might better be performed using higher level data analysis software (e.g., python or matlab). However, this script might be useful for generating quick statistics on data sets that are in GrADS format without the intermediary step of saving data to a file to read into another program.
This script is not a script that you call, but instead a library of functions that you include in your script. Note: you must include all functions as some of these functions rely on each other to operate.
In order to use this script, your data arrays must in in the format of strings with your array elements separated by spaces. e.g., array='1 2 3 4 5 6 7 8 9 10'.
Each function requires different inputs. A list of the included functions is below, as well is in a brief help page at the top of the script.
Function list
- mean(arr): Returns mean of input array "arr"
- stdev(arr): Returns Standard Deviation of input array "arr"
- sort(arr): Returns sorted array (lowest to highest) of array "arr"
- rank(arr): Returns an array size equal to array "arr" ranging from 1 to size(arr)
- percentile(arr,p): Returns the data percentile (p) of array "arr"
- size(arr): Returns the number of elements in array "arr"
- max(arr): Returns the maximum value in array "arr"
- min(arr): Returns the minimum value in array "arr"
- correlation(arr1,arr2): Returns the correlation coefficient "r" between "arr1" and "arr2"
- regression(arr1,arr2): Returns the regression coefficient between "arr1" and "arr2
Example Use:
- Calculate median of array: data='9 7 8 6 5 4 3 2 1'
say median
Outputs "5" to screen
- Sort array: data='9 7 8 6 5 4 3 2 1'
say sorted
Outputs "1 2 3 4 5 6 7 8 9" to screen
Download statpack.gs
Hi! I just found out this page, it's really helpful. But the link is invalid now, could you update it? Thank you for your sharing!!
ReplyDeleteHi Ann,
DeleteI think it is because your browser.
I swtiched from Chronme to Firefox and then it allowed me to download.