Title: | Analyze Shot Group Data |
---|---|
Description: | Analyzes shooting data with respect to group shape, precision, and accuracy. This includes graphical methods, descriptive statistics, and inference tests using standard, but also non-parametric and robust statistical methods. Implements distributions for radial error in bivariate normal variables. Works with files exported by 'OnTarget PC/TDS', 'Silver Mountain' e-target, 'ShotMarker' e-target, or 'Taran', as well as with custom data files in text format. Supports inference from range statistics such as extreme spread. Includes a set of web-based graphical user interfaces. |
Authors: | Daniel Wollschlaeger |
Maintainer: | Daniel Wollschlaeger <[email protected]> |
License: | GPL (>= 2) |
Version: | 0.8.2 |
Built: | 2024-12-04 07:29:24 UTC |
Source: | CRAN |
The shotGroups
package provides functions to read in, plot, statistically describe, analyze, and compare shooting data with respect to group shape, precision, and accuracy. This includes graphical methods, descriptive statistics, and inference tests using standard, but also non-parametric and robust statistical methods. Works with files exported by 'OnTarget PC/TDS', 'Silver Mountain' e-target, 'ShotMarker' e-target, or 'Taran', as well as with custom data files in text format. Supports inference from range statistics such as extreme spread. Includes web-based graphical user interface.
Package: | shotGroups |
Type: | Package |
Version: | 0.8.2 |
Date: | 2022-09-17 |
Depends: | R (>= 3.5.0) |
Imports: | boot, coin, CompQuadForm (>= 1.4.2), graphics, grDevices, KernSmooth, robustbase, stats, tools, utils |
Suggests: | knitr, energy, mvoutlier, shiny, jsonlite, interp, MBA, bs4Dash |
License: | GPL (>= 2) |
Use help(package='shotGroups')
for a list of all functions and links to the detailed help pages with information on options, usage and output. For further explanantions and an example walkthrough, see vignette('shotGroups')
.
Daniel Wollschlaeger
Maintainer: Daniel Wollschlaeger [email protected]
groupSpread(DFcciHV, dstTarget=100, conversion='yd2in', bootCI='none')
groupSpread(DFcciHV, dstTarget=100, conversion='yd2in', bootCI='none')
Performs a comprehensive numerical and graphical analysis of a single group of bullet holes.
analyzeGroup(DF, xyTopLeft = TRUE, center = FALSE, dstTarget, conversion, bandW = 0.5, CEPtype = 'CorrNormal', bootCI = 'none')
analyzeGroup(DF, xyTopLeft = TRUE, center = FALSE, dstTarget, conversion, bandW = 0.5, CEPtype = 'CorrNormal', bootCI = 'none')
DF |
a data frame containing (at least) either the variables |
xyTopLeft |
logical: is the origin of the absolute coordinate system in the top-left corner? See details. |
center |
logical: center groups to mean (0,0) first? If variable |
dstTarget |
a numerical value giving the distance to the target - used in MOA calculation. Acts as override if variable |
conversion |
how to convert the measurement unit for distance to target to that of the (x,y)-coordinates in MOA calculation. Acts as override if variables |
bandW |
for argument |
CEPtype |
string vector indicating which CEP estimate to report in |
bootCI |
a character vector to select which bootstrap confidence interval type to report. Possible types are |
By default, OnTarget PC/TDS' 'Export Point Data' places the origin of the absolute coordinate system in the top-left corner. In OnTarget TDS, this setting can be changed by checking the box 'Tools -> Options -> Options tab -> Data Export -> Invert Y-Axis on Export'. In that case, use xyTopLeft=FALSE
. If groups appear to be upside-down, xyTopLeft
is the setting to change.
Robust estimates for the group center and the covariance matrix of (x,y)-coordinates are from covMcd
using the MCD algorithm.
This function is a wrapper for groupShape
, groupLocation
, and groupSpread
.
If the data is missing information about the point of aim, (0,0) is assumed. If distance to target is missing, 100 is assumed.
The number of replicates for the reported bootstrap confidence intervals is at least 1499. If the BCa interval is reported, it is at least the number of points.
In addition to the numerical results listed below, this function produces the following diagrams:
a combined plot for multivariate outlier identification as produced by aq.plot
a scatterplot of the (x,y)-coordinates together with group center, circle with average distance to center, 50%-confidence ellipse - the latter also based on a robust estimate for the covariance matrix
a scatterplot of the (x,y)-coordinates together with the minimum bounding box, minimum enclosing circle, and maximum group spread
a chi-square Q-Q-plot for eyeballing multivariate normality as produced by chisq.plot
, including a reference line with intercept 0 and slope 1
a heatmap of a 2D-kernel density estimate for the (x,y)-coordinates as produced by smoothScatter
together with group center and error ellipse based on a robust estimate for the covariance matrix
a Q-Q-plot of x-coordinates for eyeballing normality
a Q-Q-plot of y-coordinates for eyeballing normality
a histogram of x-coordinates including a fitted normal distribution as well as a non-parametric kernel density estimate
a histogram of y-coordinates including a fitted normal distribution as well as a non-parametric kernel density estimate
a histogram of distances to group center including a fitted Rayleigh distribution as well as a non-parametric kernel density estimate
A list with the results from the numerical analyses and statistical tests.
corXY |
correlation matrix of (x,y)-coordinates. |
corXYrob |
robust estimate of correlation matrix of (x,y)-coordinates. |
Outliers |
a vector of row indices for observations identified as outliers. |
ShapiroX |
Shapiro-Wilk-Test result for normality of x-coordinates. |
ShapiroY |
Shapiro-Wilk-Test result for normality of y-coordinates. |
multNorm |
E-statistic-Test result for multivariate normality of (x,y)-coordinates. |
sdXY |
standard deviations of x- and y-coordinates (in original measurement units, MOA, SMOA, milliradian). |
sdXci |
parametric and bootstrap confidence intervals for the standard deviation of x-coordinates (in original measurement units, MOA, SMOA, milliradian). |
sdYci |
parametric and bootstrap confidence intervals for the standard deviation of y-coordinates (in original measurement units, MOA, SMOA, milliradian). |
sdXYrob |
robust standard deviations of x- and y-coordinates (in original measurement units, MOA, SMOA, milliradian). |
covXY |
covariance matrix of (x,y)-coordinates. |
covXYrob |
robust estimate of covariance matrix of (x,y)-coordinates. |
distToCtr |
mean and median distance from points to their center as well as estimated Rayleigh parameters sigma (precision), radial standard deviation RSD, and mean radius MR (in original measurement units, MOA, SMOA, milliradian). |
sigmaCI |
95%-parametric and bootstrap confidence intervals for sigma (in original measurement units, MOA, SMOA, milliradian). |
RSDci |
95%-parametric and bootstrap confidence intervals for radial standard deviation RSD (in original measurement units, MOA, SMOA, milliradian). |
MRci |
95%-parametric and bootstrap confidence intervals for mean radius MR (in original measurement units, MOA, SMOA, milliradian). |
maxPairDist |
maximum pairwise distance between points (center-to-center, = maximum spread, in original measurement units, MOA, SMOA, milliradian). |
groupRect |
width and height of bounding box with diagonal and figure of merit FoM (average side length, in original measurement units, MOA, SMOA, milliradian). |
groupRectMin |
width and height of minimum-area bounding box with diagonal and figure of merit FoM (average side length, in original measurement units, MOA, SMOA, milliradian). |
minCircleRad |
radius for the minimum enclosing circle (in original measurement units, MOA, SMOA, milliradian). |
confEll |
length of semi-major and semi-minor axis of the 50%-confidence ellipse (in original measurement units, MOA, SMOA, milliradian). |
confEllRob |
length of semi-major and semi-minor axis of the 50%-confidence ellipse based on a robust estimate for the covariance matrix (in original measurement units, MOA, SMOA, milliradian). |
confEllShape |
aspect ratio and flattening of the 50%-confidence ellipse. |
confEllShapeRob |
aspect ratio and flattening of the 50%-confidence ellipse based on a robust estimate for the covariance matrix. |
CEP |
estimate(s) for the 50%-circular error probable (CEP, in original measurement units, MOA, SMOA, milliradian). |
ctr |
(x,y)-offset of group center relative to point of aim. |
ctrXci |
95%-parametric and bootstrap confidence intervals for center x-coordinate. |
ctrYci |
95%-parametric and bootstrap confidence intervals for center y-coordinate. |
ctrRob |
robust estimate of group center offset relative to point of aim (MCD algorithm). |
distPOA |
distance from group center to point of aim (in original measurement units, MOA, SMOA, milliradian). |
distPOArob |
distance from robust estimate of group center to point of aim (in original measurement units, MOA, SMOA, milliradian). |
Hotelling |
Hotelling's T^2-Test result from testing if group center equals point of aim. |
groupShape
,
groupLocation
,
groupSpread
,
compareGroups
,
getDistToCtr
,
getMaxPairDist
,
getBoundingBox
,
getMinBBox
,
getMinCircle
,
getConfEll
,
getCEP
,
getRayParam
,
getMOA
,
smoothScatter
,
chisq.plot
,
aq.plot
,
pcout
,
qqnorm
,
hist
,
kernel
,
shapiro.test
,
mvnorm.etest
,
anova.mlm
,
boot
,
boot.ci
,
covMcd
data(DFinch) # select combined data from only first 2 series DF <- subset(DFinch, series %in% 1:2) res <- analyzeGroup(DF, conversion='yd2in', bootCI='none') names(res) res$multNorm res$corXY res$ctrRob res$ctrXci res$ctrYci
data(DFinch) # select combined data from only first 2 series DF <- subset(DFinch, series %in% 1:2) res <- analyzeGroup(DF, conversion='yd2in', bootCI='none') names(res) res$multNorm res$corXY res$ctrRob res$ctrXci res$ctrYci
Combines a list of data frames (the result from using readDataOT1
, readDataOT2
, or readDataMisc
with combine=FALSE
) into one big data frame.
combineData(DFs)
combineData(DFs)
DFs |
a list of data frames with a shared set of variables. |
Assumes that the data frames in the list have a non-empty set of shared variables. Among them at least either point.x
, point.y
or x
, y
defining the bullet holes. To be useful for functions analyzeGroup
or compareGroups
, the data frames should also have variables group
, distance
, aim.x
, aim.y
defining point of aim. If group
is missing, it is set to 1.
A data frame with the shared set of variables. In addition, it also contains factors identifying the original file (file
), and a factor identifying all groups from different data frames (series
).
... |
the shared set of variables from the the data frames in the list. |
group |
a factor that is the original |
groupVerb |
a factor that codes group with more descriptive levels taken from the original project title, file name and ammunition (if available). |
file |
a factor that codes from which original file the data is. |
series |
a factor that codes each separate group across original files. |
seriesNum |
a factor that codes each separate group as a number that runs consecutively across original files. |
readDataMisc
,
readDataOT1
,
readDataOT2
,
analyzeGroup
,
compareGroups
## combine list of data frames to one single data frame data(DFlistCm) DFcm <- combineData(DFlistCm) str(DFcm) head(DFcm)
## combine list of data frames to one single data frame data(DFlistCm) DFcm <- combineData(DFlistCm) str(DFcm) head(DFcm)
Numerically and graphically compare accuracy, precision, and distribution shape of up to 15 groups of bullet holes.
compareGroups(DF, plots = TRUE, xyTopLeft = TRUE, center = FALSE, ABalt = c('two.sided', 'less', 'greater'), Walt = c('two.sided', 'less', 'greater'), CEPtype = 'CorrNormal', CEPlevel = 0.5, CIlevel = 0.95, dstTarget, conversion)
compareGroups(DF, plots = TRUE, xyTopLeft = TRUE, center = FALSE, ABalt = c('two.sided', 'less', 'greater'), Walt = c('two.sided', 'less', 'greater'), CEPtype = 'CorrNormal', CEPlevel = 0.5, CIlevel = 0.95, dstTarget, conversion)
DF |
a data frame containing (at least) these variables: |
plots |
logical: show diagrams? |
xyTopLeft |
logical: is the origin of the absolute coordinate system in the top-left corner? See details. |
center |
logical: center groups to mean (0,0) first to compare only with respect to precision? |
ABalt |
a character string indicating the hypothesis for the Ansari-Bradley-Test for equal variances. Only used when exactly 2 groups are compared. |
Walt |
a character string indicating the hypothesis for the Wilcoxon-Rank-Sum-Test for equality of average distance to group center (equivalent to the Mann-Whitney-U-Test). Only used when exactly 2 groups are compared. |
CEPtype |
string indicating which CEP estimate to report from |
CEPlevel |
a numerical value giving the coverage of the confidence ellipse and CEP. |
CIlevel |
a numerical value giving the level for the confidence intervals (for standard deviations and Rayleigh sigma, MR). |
dstTarget |
a numerical value giving the distance to the target - used in MOA calculation. Acts as override if variable |
conversion |
how to convert the measurement unit for distance to target to that of the (x,y)-coordinates in MOA calculation. Acts as override if variables |
By default, OnTarget PC/TDS' 'Export Point Data' places the origin of the absolute coordinate system in the top-left corner. In OnTarget TDS, this setting can be changed by checking the box 'Tools -> Options -> Options tab -> Data Export -> Invert Y-Axis on Export'. In that case, use xyTopLeft=FALSE
. If groups appear to be upside-down, xyTopLeft
is the setting to change.
OnTarget PC/TDS' Group
variable identifies groups just within one file, whereas factor series
is taken to number groups also across different original files. If your data was read with readDataOT1
, readDataOT2
or readDataMisc
, series
is added automatically. For data from just one file, you can otherwise copy variable group
to series
in a data frame called shots
with shots$series
<-
shots$group
.
If the data is missing information about the point of aim, (0,0) is assumed. If distance to target is missing, 100 is assumed.
In addition to the numerical results listed below, this function produces the following diagrams:
a scatterplot showing all groups as well as their respective center and confidence ellipse
a scatterplot showing all groups as well as their respective (minimum) bounding box and maximum group spread
a scatterplot showing all groups as well as their respective minimum enclosing circle and circle with average distance to center
a boxplot for the distances to group center per group
a stripchart showing the distances to group center per group together with the estimated Rayleigh mean radius and its confidence interval
If package shiny
is installed, an interactive web app for this functionality can be run with runGUI("analyze")
.
A list with the results from numerical comparisons and statistical tests.
ctr |
group center offset from the respective point of aim. |
distPOA |
distances from group centers to point of aim (in original measurement units, MOA, SMOA, milliradian). |
MANOVA |
MANOVA result from testing equality of group center offset from the respective point of aim (test statistic is Wilk's lambda). |
corXY |
group correlation matrices for the (x,y)-coordinates. |
sdXY |
list with group standard deviations of the x- and y-coordinates (in original measurement units, MOA, SMOA, milliradian). |
sdXYci |
list with group parametric (chi^2) confidence intervals for the standard deviations of x- and y coordinates (in original measurement units, MOA, SMOA, milliradian). |
meanDistToCtr |
average distances from points to their respective group center (in original measurement units, MOA, SMOA, milliradian). |
maxPairDist |
maximum pairwise distance between points for each group (center-to-center, = maximum spread, in original measurement units, MOA, SMOA, milliradian). |
bbFoM |
minimum-area bounding box figure of merit (average side length) for each group (in original measurement units, MOA, SMOA, milliradian). |
bbDiag |
minimum-area bounding box diagonal length for each group (in original measurement units, MOA, SMOA, milliradian). |
minCircleRad |
radius of the minimum enclosing circle for each group (in original measurement units, MOA, SMOA, milliradian). |
sigma |
estimated Rayleigh parameter sigma (precision) for each group (in original measurement units, MOA, SMOA, milliradian). |
MR |
estimated Rayleigh mean radius for each group (in original measurement units, MOA, SMOA, milliradian). |
sigmaMRci |
parametric (chi^2) confidence intervals for Rayleigh sigma and MR (in original measurement units, MOA, SMOA, milliradian). |
CEP |
Estimate for the circular error probable (CEP) in each group (in original measurement units, MOA, SMOA, milliradian). |
AnsariX |
Ansari-Bradley-Test result from testing equality of group variances for x-coordinates. When two groups are compared. |
AnsariY |
Ansari-Bradley-Test result from testing equality of group variances for y-coordinates. When two groups are compared. |
Wilcoxon |
Wilcoxon-Rank-Sum-Test result from testing equality of average point distances to their respective group center. When two groups are compared. |
FlignerX |
Fligner-Killeen-Test result from testing equality of group variances for x-coordinates. When more than two groups are compared. |
FlignerY |
Fligner-Killeen-Test result from testing equality of group variances for y-coordinates. When more than two groups are compared. |
Kruskal |
Kruskal-Wallis-Test result from testing equality of average point distances to their respective group center. When more than two groups are compared. |
analyzeGroup
,
getDistToCtr
,
getMaxPairDist
,
getMinBBox
,
getMinCircle
,
getCEP
,
getMOA
,
getRayParam
,
drawEllipse
,
anova.mlm
,
ansari_test
,
fligner_test
,
wilcox_test
,
kruskal_test
cmp <- compareGroups(DF300BLKhl, dstTarget=100, conversion='yd2in') names(cmp) cmp$ctr cmp$meanDistToCtr cmp$CEP cmp$Kruskal
cmp <- compareGroups(DF300BLKhl, dstTarget=100, conversion='yd2in') names(cmp) cmp$ctr cmp$meanDistToCtr cmp$CEP cmp$Kruskal
Example of a data frame from one file with one group of bullet holes.
data(DF300BLK)
data(DF300BLK)
A data frame with 20 observations on the following 9 variables.
group
a factor with level 1
.
distance
a numerical vector giving the distance to the target.
aim.x
a numerical vector of x-coordinates giving the point of aim.
aim.y
a numerical vector of y-coordinates giving the of point of aim.
point.x
a numerical vector of absolute x-coordinates of bullet holes.
point.y
a numerical vector of absolute y-coordinates of bullet holes.
origin
a factor with level 1
. This factor codes from which original output file the data is.
orgser
a factor with level 1.1
. This factor results from droplevels(interaction(origin, group))
, and codes each separate group across original files. The order of the factor levels is alphabetical.
series
a factor with level 1
. This factor codes each separate group as defined by orgser
, but more conveniently as a number that runs consecutively across original files.
distance.unit
Measurement unit distance to target
point.unit
Measurement unit (x,y)-coordinates
One group of shooting a Noveske AR-15 rifle in 300BLK at 100yd with factory ammunition. The measurement unit for coordinates is inch, for distance yards.
This data frame is like those returned by readDataOT1
, readDataOT2
, or readDataMisc
with option combine=TRUE
.
Data courtesy of David Bookstaber, 2013. http://ballistipedia.com/
combineData
,
analyzeGroup
,
compareGroups
data(DF300BLK) str(DF300BLK)
data(DF300BLK) str(DF300BLK)
Example of a data frame from one file with one group of bullet holes.
data(DF300BLK)
data(DF300BLK)
A data frame with 60 observations on the following 9 variables.
group
a factor with level 1
.
distance
a numerical vector giving the distance to the target.
aim.x
a numerical vector of x-coordinates giving the point of aim.
aim.y
a numerical vector of y-coordinates giving the of point of aim.
point.x
a numerical vector of absolute x-coordinates of bullet holes.
point.y
a numerical vector of absolute y-coordinates of bullet holes.
origin
a factor with level 1
. This factor codes from which original output file the data is.
orgser
a factor with levels 1.1
, 1.2
, 1.3
. This factor results from droplevels(interaction(origin, group))
, and codes each separate group across original files. The order of the factor levels is alphabetical.
series
a factor with levels 1
, 2
, 3
. This factor codes each separate group as defined by orgser
, but more conveniently as a number that runs consecutively across original files.
distance.unit
Measurement unit distance to target
point.unit
Measurement unit (x,y)-coordinates
Three groups of shooting a Noveske AR-15 rifle in 300BLK at 100yd with handloaded ammunition. The measurement unit for coordinates is inch, for distance yards.
This data frame is like those returned by readDataOT1
, readDataOT2
, or readDataMisc
with option combine=TRUE
.
Data courtesy of David Bookstaber, 2014. http://ballistipedia.com/
combineData
,
analyzeGroup
,
compareGroups
data(DF300BLK) str(DF300BLK)
data(DF300BLK) str(DF300BLK)
Example of a data frame from one file with two groups of bullet holes.
data(DFcciHV)
data(DFcciHV)
A data frame with 40 observations on the following 9 variables.
group
a factor with levels 1
2
.
distance
a numerical vector giving the distance to the target.
aim.x
a numerical vector of x-coordinates giving the point of aim.
aim.y
a numerical vector of y-coordinates giving the of point of aim.
point.x
a numerical vector of absolute x-coordinates of bullet holes.
point.y
a numerical vector of absolute y-coordinates of bullet holes.
origin
a factor with levels 1
. This factor codes from which original output file the data is.
orgser
a factor with levels 1.1
1.2
. This factor results from droplevels(interaction(origin, group))
, and codes each separate group across original files. The order of the factor levels is alphabetical.
series
a factor with levels 1
2
. This factor codes each separate group as defined by orgser
, but more conveniently as a number that runs consecutively across original files.
distance.unit
Measurement unit distance to target
point.unit
Measurement unit (x,y)-coordinates
Two groups of shooting a PWS T3 rifle in .22LR at 100yd. The measurement unit for coordinates is inch, for distance yards.
This data frame is like those returned by readDataOT1
, readDataOT2
, or readDataMisc
with option combine=TRUE
.
Data courtesy of David Bookstaber, 2013. http://ballistipedia.com/
combineData
,
analyzeGroup
,
compareGroups
data(DFcciHV) str(DFcciHV)
data(DFcciHV) str(DFcciHV)
Example of a combined data frame from several files exported by OnTarget PC/TDS, each with several groups of bullet holes.
data(DFcm)
data(DFcm)
A data frame with 487 observations on the following 13 variables.
project.title
a character vector giving the OnTarget PC/TDS project title.
group
a factor with levels 1
2
3
. This is the original Group
variable as defined by OnTarget PC/TDS.
ammunition
a character vector describing the ammo.
distance
a numerical vector giving the distance to the target.
aim.x
a numerical vector of x-coordinates giving the point of aim.
aim.y
a numerical vector of y-coordinates giving the of point of aim.
center.x
a numerical vector of x-coordinates giving the group centers.
center.y
a numerical vector of y-coordinates giving the group centers.
point.x
a numerical vector of absolute x-coordinates of bullet holes.
point.y
a numerical vector of absolute y-coordinates of bullet holes.
origin
a factor with levels 1
2
3
. This factor codes from which original output file the data is.
orgser
a factor with levels 1.1
2.1
3.1
1.2
2.2
3.2
1.3
2.3
3.3
. This factor results from droplevels(interaction(origin, group))
, and codes each separate group across original files. The order of the factor levels is alphabetical.
series
a factor with levels 1
2
3
4
5
6
7
8
9
. This factor codes each separate group as defined by orgser
, but more conveniently as a number that runs consecutively across original files.
distance.unit
Measurement unit distance to target
point.unit
Measurement unit (x,y)-coordinates
target
Character string "BDS9"
indicating the target face. See targets
.
Several groups of shooting a 9x19mm pistol at 25m. The measurement unit for coordinates is cm, for distance meters.
This data frame is like those returned by readDataOT1
, readDataOT2
, or readDataMisc
with option combine=TRUE
.
combineData
,
analyzeGroup
,
compareGroups
data(DFcm) str(DFcm)
data(DFcm) str(DFcm)
Lookup table for the distribution of range statistics and Rayleigh sigma from a Monte Carlo simulation of circular bivariate normal shot groups with 0 mean and variance 1 in both directions. Includes the first four moments and several quantiles of the distribution of extreme spread, figure of merit, bounding box diagonal, and Rayleigh sigma for each combination of number of shots per group and number of groups, repeated 10 million times.
data(DFdistr)
data(DFdistr)
A data frame with 590 observations on the following 77 variables.
number of shots in each group. One of 2, 3, ..., 49, 50, 45, ..., 95, 100.
number of groups with individual simulated range statistics that were averaged over to yield the final value. One of 1, 2, ..., 9, 10.
total number of shots, i.e., n*nGroups
.
Extreme spread mean over all Monte Carlo simulations
Extreme spread variance over all Monte Carlo simulations
Extreme spread standard deviation over all Monte Carlo simulations
Extreme spread coefficient of variation over all Monte Carlo simulations
Squard extreme spread mean over all Monte Carlo simulations
Squared extreme spread variance over all Monte Carlo simulations
Extreme spread skewness over all Monte Carlo simulations (smoothed)
Extreme spread kurtosis over all Monte Carlo simulations (smoothed)
Extreme spread median (50% quantile) over all Monte Carlo simulations
Extreme spread 0.5% quantile over all Monte Carlo simulations
Extreme spread 2.5% quantile over all Monte Carlo simulations
Extreme spread 5% quantile over all Monte Carlo simulations
Extreme spread 10% quantile over all Monte Carlo simulations
Extreme spread 25% quantile over all Monte Carlo simulations
Extreme spread 50% quantile (median) over all Monte Carlo simulations
Extreme spread 75% quantile over all Monte Carlo simulations
Extreme spread 90% quantile over all Monte Carlo simulations
Extreme spread 95% quantile over all Monte Carlo simulations
Extreme spread 97.5% quantile over all Monte Carlo simulations
Extreme spread 99.5% quantile over all Monte Carlo simulations
Figure of merit mean over all Monte Carlo simulations
Figure of merit variance over all Monte Carlo simulations
Figure of merit standard deviation over all Monte Carlo simulations
Figure of merit coefficient of variation over all Monte Carlo simulations
Figure of merit skewness over all Monte Carlo simulations (smoothed)
Figure of merit kurtosis over all Monte Carlo simulations (smoothed)
Figure of merit median (50% quantile) over all Monte Carlo simulations
Figure of merit 0.5% quantile over all Monte Carlo simulations
Figure of merit 2.5% quantile over all Monte Carlo simulations
Figure of merit 0.25% quantile over all Monte Carlo simulations
Figure of merit 10% quantile over all Monte Carlo simulations
Figure of merit 25% quantile over all Monte Carlo simulations
Figure of merit 50% quantile (median) over all Monte Carlo simulations
Figure of merit 75% quantile over all Monte Carlo simulations
Figure of merit 90% quantile over all Monte Carlo simulations
Figure of merit 95% quantile over all Monte Carlo simulations
Figure of merit 97.5% quantile over all Monte Carlo simulations
Figure of merit 99.5% quantile over all Monte Carlo simulations
Bounding box diagonal mean over all Monte Carlo simulations
Bounding box diagonal variance over all Monte Carlo simulations
Bounding box diagonal standard deviation over all Monte Carlo simulations
Bounding box diagonal coefficient of variation over all Monte Carlo simulations
Bounding box diagonal skewness over all Monte Carlo simulations (smoothed)
Bounding box diagonal kurtosis over all Monte Carlo simulations (smoothed)
Bounding box diagonal median (50% quantile) over all Monte Carlo simulations
Bounding box diagonal 0.5% quantile over all Monte Carlo simulations
Bounding box diagonal 2.5% quantile over all Monte Carlo simulations
Bounding box diagonal 5% quantile over all Monte Carlo simulations
Bounding box diagonal 10% quantile over all Monte Carlo simulations
Bounding box diagonal 25% quantile over all Monte Carlo simulations
Bounding box diagonal 50% quantile (median) over all Monte Carlo simulations
Bounding box diagonal 75% quantile over all Monte Carlo simulations
Bounding box diagonal 90% quantile over all Monte Carlo simulations
Bounding box diagonal 95% quantile over all Monte Carlo simulations
Bounding box diagonal 97.5% quantile over all Monte Carlo simulations
Bounding box diagonal 99.5% quantile over all Monte Carlo simulations
Rayleigh sigma mean over all Monte Carlo simulations
Rayleigh sigma variance over all Monte Carlo simulations
Rayleigh sigma standard deviation over all Monte Carlo simulations
Rayleigh sigma coefficient of variation over all Monte Carlo simulations
Rayleigh sigma skewness over all Monte Carlo simulations (smoothed)
Rayleigh sigma kurtosis over all Monte Carlo simulations (smoothed)
Rayleigh sigma median (50% quantile) over all Monte Carlo simulations
Rayleigh sigma 0.5% quantile over all Monte Carlo simulations
Rayleigh sigma 2.5% quantile over all Monte Carlo simulations
Rayleigh sigma 5% quantile over all Monte Carlo simulations
Rayleigh sigma 10% quantile over all Monte Carlo simulations
Rayleigh sigma 25% quantile over all Monte Carlo simulations
Rayleigh sigma 50% quantile (median) over all Monte Carlo simulations
Rayleigh sigma 75% quantile over all Monte Carlo simulations
Rayleigh sigma 90% quantile over all Monte Carlo simulations
Rayleigh sigma 95% quantile over all Monte Carlo simulations
Rayleigh sigma 97.5% quantile over all Monte Carlo simulations
Rayleigh sigma 99.5% quantile over all Monte Carlo simulations
The Monte Carlo distribution used 10 million repetitions in each scenario. One scenario was a combination of the n
shots in each group, and the nGroups
groups over which individual range statistics were averaged. Values for n
were 2, 3, ..., 49, 50, 45, ..., 95, 100. Values for nGroups
were 1, 2, ... 9, 10.
Skewness and kurtosis were smoothed using separate linear spline fits for each number of groups except for kurtosis of Rayleigh sigma which was fitted using the density of the gamma distribution.
Used in range2sigma
to estimate Rayleigh parameter sigma from range statistics, and in efficiency
to estimate the number of groups and total shots required to estimate the confidence interval (CI) for Rayleigh sigma with a given coverage probability (CI level) and width.
See the following source for an independent simulation, and for the rationale behind using it to estimate Rayleigh sigma:
http://ballistipedia.com/index.php?title=Range_Statistics
An older eqivalent simulation with less repetitions was done by Taylor and Grubbs (1975).
Taylor, M. S., & Grubbs, F. E. (1975). Approximate Probability Distributions for the Extreme Spread (BRL-MR-2438). Aberdeen Proving Ground, MD: U.S. Ballistic Research Laboratory.
range2sigma
,
efficiency
,
getMaxPairDist
,
getBoundingBox
,
getRayParam
data(DFdistr) str(DFdistr)
data(DFdistr) str(DFdistr)
Example of a combined data frame from several files exported by OnTarget PC/TDS, each with several groups of bullet holes.
data(DFinch)
data(DFinch)
A data frame with 487 observations on the following 13 variables.
project.title
a character vector giving the OnTarget PC/TDS project title.
group
a factor with levels 1
2
3
. This is the original Group
variable as defined by OnTarget PC/TDS.
ammunition
a character vector describing the ammo.
distance
a numerical vector giving the distance to the target.
aim.x
a numerical vector of x-coordinates giving the point of aim.
aim.y
a numerical vector of y-coordinates giving the of point of aim.
center.x
a numerical vector of x-coordinates giving the group centers.
center.y
a numerical vector of y-coordinates giving the group centers.
point.x
a numerical vector of absolute x-coordinates of bullet holes.
point.y
a numerical vector of absolute y-coordinates of bullet holes.
origin
a factor with levels 1
2
3
. This factor codes from which original output file the data is.
orgser
a factor with levels 1.1
2.1
3.1
1.2
2.2
3.2
1.3
2.3
3.3
. This factor results from droplevels(interaction(origin, group))
, and codes each separate group across original files. The order of the factor levels is alphabetical.
series
a factor with levels 1
2
3
4
5
6
7
8
9
. This factor codes each separate group as defined by orgser
, but more conveniently as a number that runs consecutively across original files.
distance.unit
Measurement unit distance to target
point.unit
Measurement unit (x,y)-coordinates
target
Character string "BDS9"
indicating the target face. See targets
Several groups of shooting a 9x19mm pistol at 27yd. The measurement unit for coordinates is inch, for distance yards.
This data frame is like those returned by readDataOT1
, readDataOT2
, or readDataMisc
with option combine=TRUE
.
combineData
,
analyzeGroup
,
compareGroups
data(DFinch) str(DFinch)
data(DFinch) str(DFinch)
Example of a data frame from one file with one group of bullet holes.
data(DFlandy01)
data(DFlandy01)
A data frame with 530 observations on the following 15 variables.
group
a numerical vector with group numbers 1 to 53.
distance
a numerical vector giving the distance to the target.
aim.x
a numerical vector of x-coordinates giving the point of aim.
aim.y
a numerical vector of y-coordinates giving the of point of aim.
point.x
a numerical vector of absolute x-coordinates of bullet holes.
point.y
a numerical vector of absolute y-coordinates of bullet holes.
ammunition
a character vector giving ammunition and lot number.
velocity
a numerical vector of chronograph readings in ft/s.
control
undocumented.
phase1
undocumented.
phase2
undocumented.
file
a character vector with the original file name.
groupVerb
a character vector designating the group by combining the original file name and ammunition.
series
a character vector that codes each separate group in an alternative way.
seriesNum
like series
but numeric.
distance.unit
Measurement unit distance to target
point.unit
Measurement unit (x,y)-coordinates
53 groups with 10 shots each of .22LR shot at Eley test center on Oct 2 2016 using a Stiller 2500X action at a distance of 50m. The measurement unit for coordinates is mm, for distance m.
This data frame is like those returned by readDataOT1
, readDataOT2
, or readDataMisc
with option combine=TRUE
.
Data courtesy of Larry Landercasper, 2017. Analyzed by Albert Highe.
combineData
,
analyzeGroup
,
compareGroups
data(DFlandy01) str(DFlandy01)
data(DFlandy01) str(DFlandy01)
Example of a data frame from one file with one group of bullet holes.
data(DFlandy02)
data(DFlandy02)
A data frame with 100 observations on the following 12 variables.
group
a numerical vector with group numbers 1, 2.
distance
a numerical vector giving the distance to the target.
aim.x
a numerical vector of x-coordinates giving the point of aim.
aim.y
a numerical vector of y-coordinates giving the of point of aim.
point.x
a numerical vector of absolute x-coordinates of bullet holes.
point.y
a numerical vector of absolute y-coordinates of bullet holes.
ammunition
a character vector giving ammunition and lot number.
velocity
a numerical vector of chronograph readings in ft/s.
file
a character vector with the original file name.
groupVerb
a character vector designating the group by combining the original file name and ammunition.
series
a character vector that codes each separate group in an alternative way.
seriesNum
like series
but numeric.
distance.unit
Measurement unit distance to target
point.unit
Measurement unit (x,y)-coordinates
2 groups with 50 shots each of .22LR shot using a Stiller 2500X action at a distance of 50yd. The measurement unit for coordinates is inch, for distance yards. Group 1 is from the best of 3 lots, group 2 from worst of 3 lots.
This data frame is like those returned by readDataOT1
, readDataOT2
, or readDataMisc
with option combine=TRUE
.
Data courtesy of Larry Landercasper, 2017.
combineData
,
analyzeGroup
,
compareGroups
data(DFlandy02) str(DFlandy02)
data(DFlandy02) str(DFlandy02)
Example of a data frame from one file with one group of bullet holes.
data(DFlandy03)
data(DFlandy03)
A data frame with 100 observations on the following 12 variables.
group
a numerical vector with group numbers 1, 2.
distance
a numerical vector giving the distance to the target.
aim.x
a numerical vector of x-coordinates giving the point of aim.
aim.y
a numerical vector of y-coordinates giving the of point of aim.
point.x
a numerical vector of absolute x-coordinates of bullet holes.
point.y
a numerical vector of absolute y-coordinates of bullet holes.
ammunition
a character vector giving ammunition and lot number.
velocity
a numerical vector of chronograph readings in ft/s.
file
a character vector with the original file name.
groupVerb
a character vector designating the group by combining the original file name and ammunition.
series
a character vector that codes each separate group in an alternative way.
seriesNum
like series
but numeric.
distance.unit
Measurement unit distance to target
point.unit
Measurement unit (x,y)-coordinates
4 groups with 25 shots each of .22LR shot at a distance of 50yd. The measurement unit for coordinates is inch, for distance yards.
Data courtesy of Larry Landercasper, 2017.
combineData
,
analyzeGroup
,
compareGroups
data(DFlandy03) str(DFlandy03)
data(DFlandy03) str(DFlandy03)
Example of a data frame from one file with one group of bullet holes.
data(DFlandy04)
data(DFlandy04)
A data frame with 100 observations on the following 12 variables.
group
a numerical vector with group numbers 1, 2.
distance
a numerical vector giving the distance to the target.
aim.x
a numerical vector of x-coordinates giving the point of aim.
aim.y
a numerical vector of y-coordinates giving the of point of aim.
point.x
a numerical vector of absolute x-coordinates of bullet holes.
point.y
a numerical vector of absolute y-coordinates of bullet holes.
ammunition
a character vector giving ammunition and lot number.
velocity
a numerical vector of chronograph readings in ft/s.
file
a character vector with the original file name.
groupVerb
a character vector designating the group by combining the original file name and ammunition.
series
a character vector that codes each separate group in an alternative way.
seriesNum
like series
but numeric.
distance.unit
Measurement unit distance to target
point.unit
Measurement unit (x,y)-coordinates
6 groups with 25 shots each (groups 1-5) or 50 shots (group 6) of .22LR shot at a distance of 50yd. The measurement unit for coordinates is inch, for distance yards.
Groups 1-3 shot with a Stiller Copperhead action with Shilen Octagon Barrel. Group 4-5 shot with a Baity Falcon action with Shilen Ratchet Barrel. Group 6 shot with a Stiller 2500X action with Shilen Octagon Barrel.
This data frame is like those returned by readDataOT1
, readDataOT2
, or readDataMisc
with option combine=TRUE
.
Data courtesy of Larry Landercasper, 2017.
combineData
,
analyzeGroup
,
compareGroups
data(DFlandy04) str(DFlandy04)
data(DFlandy04) str(DFlandy04)
Example list containing several data frames with bullet hole data as produced by readDataOT1
, readDataOT2
, or by readDataMisc
with option combine=FALSE
.
data(DFlistCm)
data(DFlistCm)
Several groups of shooting a 9x19mm pistol at 25m. The measurement unit for coordinates is cm, for distance meters.
This list can be used as an argument for combineData
.
combineData
,
readDataMisc
,
readDataOT1
,
readDataOT2
data(DFlistCm) str(DFlistCm) ## combine list of data frames to one single data frame DFcm <- combineData(DFlistCm) str(DFcm)
data(DFlistCm) str(DFlistCm) ## combine list of data frames to one single data frame DFcm <- combineData(DFlistCm) str(DFcm)
Example of a combined data frame from several original files, each with one group.
data(DFsavage)
data(DFsavage)
A data frame with 180 observations on the following 10 variables.
point.x
a numerical vector of absolute x-coordinates of bullet holes.
point.y
a numerical vector of absolute y-coordinates of bullet holes.
aim.x
a numerical vector of x-coordinates giving the point of aim.
aim.y
a numerical vector of y-coordinates giving the of point of aim.
distance
a numerical vector giving the distance to the target.
group
a factor with level 1
. This is the original Group
variable as defined by OnTarget PC/TDS.
bullet
a character vector describing the bullet type.
origin
a factor with levels 1
... 9
. This factor codes from which original output file the data is.
orgser
a factor with levels 1.1
... 9.1
. This factor results from droplevels(interaction(Origin, Group))
, and codes each separate group across original files. The order of the factor levels is alphabetical.
series
a factor with levels 1
... 9
. This factor codes each separate group as defined by orgser
, but more conveniently as a number that runs consecutively across original files.
distance.unit
Measurement unit distance to target
point.unit
Measurement unit (x,y)-coordinates
Several groups of shooting a Savage 12 FT/R rifle in .308 Win at distances from 100 to 300m. The measurement unit for coordinates is mm, for distance meters. Shots 1-5 in series
4, and shots 1-3 in series
7 moved the scope.
This data frame is like those returned by readDataOT1
, readDataOT2
, or readDataMisc
with option combine=TRUE
.
Data copyright Charles McMillan and Paul McMillan, 2008.
combineData
,
analyzeGroup
,
compareGroups
data(DFsavage) str(DFsavage)
data(DFsavage) str(DFsavage)
Example of a data frame from one file with one group of bullet holes.
data(DFscar17)
data(DFscar17)
A data frame with 10 observations on the following 9 variables.
group
a factor with level 1
.
distance
a numerical vector giving the distance to the target.
aim.x
a numerical vector of x-coordinates giving the point of aim.
aim.y
a numerical vector of y-coordinates giving the of point of aim.
point.x
a numerical vector of absolute x-coordinates of bullet holes.
point.y
a numerical vector of absolute y-coordinates of bullet holes.
origin
a factor with level 1
. This factor codes from which original output file the data is.
orgser
a factor with level 1.1
. This factor results from droplevels(interaction(origin, group))
, and codes each separate group across original files. The order of the factor levels is alphabetical.
series
a factor with levels 1
. This factor codes each separate group as defined by orgser
, but more conveniently as a number that runs consecutively across original files.
distance.unit
Measurement unit distance to target
point.unit
Measurement unit (x,y)-coordinates
One group of shooting an FN SCAR 17 rifle in .308 Win at 100yd. The measurement unit for coordinates is inch, for distance yards.
This data frame is like those returned by readDataOT1
, readDataOT2
, or readDataMisc
with option combine=TRUE
.
Data courtesy of David Bookstaber, 2013. http://ballistipedia.com/
combineData
,
analyzeGroup
,
compareGroups
data(DFscar17) str(DFscar17)
data(DFscar17) str(DFscar17)
Example of a combined data frame from several original files, each file containing one group.
data(DFtalon)
data(DFtalon)
A data frame with 180 observations on the following 10 variables.
point.x
a numerical vector of absolute x-coordinates of bullet holes.
point.y
a numerical vector of absolute y-coordinates of bullet holes.
aim.x
a numerical vector of x-coordinates giving the point of aim.
aim.y
a numerical vector of y-coordinates giving the of point of aim.
distance
a numerical vector giving the distance to the target.
group
a factor with level 1
. This is the original Group
variable as defined by OnTarget PC/TDS.
bullet
a character vector describing the bullet type.
origin
a factor with levels 1
... 9
. This factor codes from which original output file the data is.
orgser
a factor with levels 1.1
... 9.1
. This factor results from droplevels(interaction(Origin, Group))
, and codes each separate group across original files. The order of the factor levels is alphabetical.
series
a factor with levels 1
... 9
. This factor codes each separate group as defined by orgser
, but more conveniently as a number that runs consecutively across original files.
distance.unit
Measurement unit distance to target
point.unit
Measurement unit (x,y)-coordinates
Several groups of shooting a Talon SS air rifle at 10m. The measurement unit for coordinates is mm, for distance meters.
This data frame is like those returned by readDataOT1
, readDataOT2
, or readDataMisc
with option combine=TRUE
.
Data copyright Charles McMillan and Paul McMillan, 2008.
combineData
,
analyzeGroup
,
compareGroups
data(DFtalon) str(DFtalon)
data(DFtalon) str(DFtalon)
Adds an axis-aligned box to an existing plot.
drawBox(x, fg = par('fg'), bg = NA, colCtr = NA, lty = par('lty'), lwd = par('lwd'), pch = par('pch'), cex = par('cex')) ## S3 method for class 'list' drawBox(x, fg = par('fg'), bg = NA, colCtr = NA, lty = par('lty'), lwd = par('lwd'), pch = par('pch'), cex = par('cex')) ## Default S3 method: drawBox(x, fg = par('fg'), bg = NA, colCtr = NA, lty = par('lty'), lwd = par('lwd'), pch = par('pch'), cex = par('cex'))
drawBox(x, fg = par('fg'), bg = NA, colCtr = NA, lty = par('lty'), lwd = par('lwd'), pch = par('pch'), cex = par('cex')) ## S3 method for class 'list' drawBox(x, fg = par('fg'), bg = NA, colCtr = NA, lty = par('lty'), lwd = par('lwd'), pch = par('pch'), cex = par('cex')) ## Default S3 method: drawBox(x, fg = par('fg'), bg = NA, colCtr = NA, lty = par('lty'), lwd = par('lwd'), pch = par('pch'), cex = par('cex'))
x |
either a list with component |
fg |
color of the box' rim. |
bg |
the box' fill color. Set to |
colCtr |
color of the center point. Set to |
lty |
line type of the box. |
lwd |
line width of the box. |
pch |
symbol used for the center of the box. |
cex |
magnification factor for the symbol used for the center of the box. |
This function is mainly a wrapper for rect
.
xy <- matrix(round(rnorm(20, 100, 15), 1), ncol=2) (bb <- getBoundingBox(xy)) plot(xy, asp=1, pch=16) drawBox(bb, fg='blue', colCtr='blue', pch=4, cex=2)
xy <- matrix(round(rnorm(20, 100, 15), 1), ncol=2) (bb <- getBoundingBox(xy)) plot(xy, asp=1, pch=16) drawBox(bb, fg='blue', colCtr='blue', pch=4, cex=2)
Adds an oriented box to an existing plot.
drawBox2(x, fg = par('fg'), bg = NA, colCtr = NA, lty = par('lty'), lwd = par('lwd'), pch = par('pch'), cex = par('cex')) ## S3 method for class 'list' drawBox2(x, fg = par('fg'), bg = NA, colCtr = NA, lty = par('lty'), lwd = par('lwd'), pch = par('pch'), cex = par('cex')) ## Default S3 method: drawBox2(x, fg = par('fg'), bg = NA, colCtr = NA, lty = par('lty'), lwd = par('lwd'), pch = par('pch'), cex = par('cex'))
drawBox2(x, fg = par('fg'), bg = NA, colCtr = NA, lty = par('lty'), lwd = par('lwd'), pch = par('pch'), cex = par('cex')) ## S3 method for class 'list' drawBox2(x, fg = par('fg'), bg = NA, colCtr = NA, lty = par('lty'), lwd = par('lwd'), pch = par('pch'), cex = par('cex')) ## Default S3 method: drawBox2(x, fg = par('fg'), bg = NA, colCtr = NA, lty = par('lty'), lwd = par('lwd'), pch = par('pch'), cex = par('cex'))
x |
either a list with component |
fg |
color of the box' rim. |
bg |
the box' fill color. Set to |
colCtr |
color of the center point. Set to |
lty |
line type of the box. |
lwd |
line width of the box. |
pch |
symbol used for the center of the box. |
cex |
magnification factor for the symbol used for the center of the box. |
This function is mainly a wrapper for polygon
.
xy <- matrix(round(rnorm(20, 100, 15), 1), ncol=2) (bb <- getMinBBox(xy)) plot(xy, xlim=range(c(xy[ , 1], bb$pts[ , 1])), ylim=range(c(xy[ , 2], bb$pts[ , 2])), asp=1, pch=16) drawBox2(bb, fg='blue', colCtr='blue', pch=4, cex=2)
xy <- matrix(round(rnorm(20, 100, 15), 1), ncol=2) (bb <- getMinBBox(xy)) plot(xy, xlim=range(c(xy[ , 1], bb$pts[ , 1])), ylim=range(c(xy[ , 2], bb$pts[ , 2])), asp=1, pch=16) drawBox2(bb, fg='blue', colCtr='blue', pch=4, cex=2)
Adds a circle to an existing plot.
drawCircle(x, radius, nv = 100, fg = par('fg'), bg = NA, colCtr = NA, lty = par('lty'), lwd = par('lwd'), pch = par('pch'), cex = par('cex')) ## S3 method for class 'list' drawCircle(x, radius, nv = 100, fg = par('fg'), bg = NA, colCtr = NA, lty = par('lty'), lwd = par('lwd'), pch = par('pch'), cex = par('cex')) ## Default S3 method: drawCircle(x, radius, nv = 100, fg = par('fg'), bg = NA, colCtr = NA, lty = par('lty'), lwd = par('lwd'), pch = par('pch'), cex = par('cex'))
drawCircle(x, radius, nv = 100, fg = par('fg'), bg = NA, colCtr = NA, lty = par('lty'), lwd = par('lwd'), pch = par('pch'), cex = par('cex')) ## S3 method for class 'list' drawCircle(x, radius, nv = 100, fg = par('fg'), bg = NA, colCtr = NA, lty = par('lty'), lwd = par('lwd'), pch = par('pch'), cex = par('cex')) ## Default S3 method: drawCircle(x, radius, nv = 100, fg = par('fg'), bg = NA, colCtr = NA, lty = par('lty'), lwd = par('lwd'), pch = par('pch'), cex = par('cex'))
x |
either a numerical vector giving the center's (x,y)-coordinates or a list with the components |
radius |
a numerical vector giving the circle's radius. |
nv |
number of vertices in the approximating polygon. |
fg |
color of the circle's rim. |
bg |
the circle's fill color. Set to |
colCtr |
color of the center point. Set to |
lty |
line type of the circle. |
lwd |
line width of the circle. |
pch |
symbol used for the center of the circle. |
cex |
magnification factor for the symbol used for the center of the circle. |
This function is mainly a wrapper for polygon
. To draw more than a few circles efficiently, use symbols
instead.
polygon
,
symbols
,
getMinCircle
c1 <- c(1, 2) # circle center c2 <- c(2, 3) # another circle center r1 <- 2 # circle radius r2 <- 0.5 # another circle radius # determine axis limits so that circles will be visible xLims <- c1[1] + c(-r1, r1) yLims <- c1[2] + c(-r1, r1) plot(c1[1], c1[2], type='n', asp=1, xlim=xLims, ylim=yLims) drawCircle(c1, r1, fg='blue', colCtr='blue', pch=19) drawCircle(c2, r2, fg='red', bg='red', colCtr='black', pch=4)
c1 <- c(1, 2) # circle center c2 <- c(2, 3) # another circle center r1 <- 2 # circle radius r2 <- 0.5 # another circle radius # determine axis limits so that circles will be visible xLims <- c1[1] + c(-r1, r1) yLims <- c1[2] + c(-r1, r1) plot(c1[1], c1[2], type='n', asp=1, xlim=xLims, ylim=yLims) drawCircle(c1, r1, fg='blue', colCtr='blue', pch=19) drawCircle(c2, r2, fg='red', bg='red', colCtr='black', pch=4)
Adds an ellipse to an existing plot.
drawEllipse(x, shape, radius, nv = 100, axes = FALSE, fg = par('fg'), bg = NA, colCtr = NA, lty = par('lty'), lwd = par('lwd'), pch = par('pch'), cex = par('cex')) ## S3 method for class 'list' drawEllipse(x, shape, radius, nv = 100, axes = FALSE, fg = par('fg'), bg = NA, colCtr = NA, lty = par('lty'), lwd = par('lwd'), pch = par('pch'), cex = par('cex')) ## Default S3 method: drawEllipse(x, shape, radius, nv = 100, axes = FALSE, fg = par('fg'), bg = NA, colCtr = NA, lty = par('lty'), lwd = par('lwd'), pch = par('pch'), cex = par('cex'))
drawEllipse(x, shape, radius, nv = 100, axes = FALSE, fg = par('fg'), bg = NA, colCtr = NA, lty = par('lty'), lwd = par('lwd'), pch = par('pch'), cex = par('cex')) ## S3 method for class 'list' drawEllipse(x, shape, radius, nv = 100, axes = FALSE, fg = par('fg'), bg = NA, colCtr = NA, lty = par('lty'), lwd = par('lwd'), pch = par('pch'), cex = par('cex')) ## Default S3 method: drawEllipse(x, shape, radius, nv = 100, axes = FALSE, fg = par('fg'), bg = NA, colCtr = NA, lty = par('lty'), lwd = par('lwd'), pch = par('pch'), cex = par('cex'))
x |
either a numerical 2-vector giving the (x,y)-coordinates of the center or a list with the components |
shape |
a numerical symmetric (2 x 2)-matrix whose eigen-structure determines the ellipse's shape. |
radius |
a numerical value giving the ellipse's magnification factor. |
nv |
number of vertices in the approximating polygon. |
axes |
logical: should ellipse axes be drawn? |
fg |
color of the ellipse's rim. |
bg |
the ellipse's fill color. Set to |
colCtr |
color of the center point. Set to |
lty |
line type of the ellipse. |
lwd |
line width of the ellipse. |
pch |
symbol used for the center of the ellipse. |
cex |
magnification factor for the symbol used for the center of the ellipse. |
This function is mainly a wrapper for polygon
.
polygon
,
getConfEll
,
getMinEllipse
## error ellipse for a set of points xy <- matrix(round(rnorm(100, 0, 8), 2), ncol=2) ce <- getConfEll(xy) plot(xy, pch=16, asp=1) drawEllipse(ce, radius=1, axes=TRUE, fg='blue', colCtr='blue', lwd=2, pch=4, cex=2)
## error ellipse for a set of points xy <- matrix(round(rnorm(100, 0, 8), 2), ncol=2) ce <- getConfEll(xy) plot(xy, pch=16, asp=1) drawEllipse(ce, radius=1, axes=TRUE, fg='blue', colCtr='blue', lwd=2, pch=4, cex=2)
Draws a group with scaled bullet holes on a target background. Spread measures can be selected individually.
drawGroup(xy, center = FALSE, xyTopLeft = TRUE, bb = FALSE, bbMin = FALSE, bbDiag = FALSE, minCirc = FALSE, minEll = FALSE, maxSpread = FALSE, meanDist = FALSE, confEll = FALSE, CEP = FALSE, ringID = FALSE, valueID = TRUE, doRob = FALSE, level = 0.95, scaled = TRUE, caliber = 9, dstTarget, conversion, unit = 'unit', alpha = 0.5, target) ## S3 method for class 'data.frame' drawGroup(xy, center = FALSE, xyTopLeft = TRUE, bb = FALSE, bbMin = FALSE, bbDiag = FALSE, minCirc = FALSE, minEll = FALSE, maxSpread = FALSE, meanDist = FALSE, confEll = FALSE, CEP = FALSE, ringID = FALSE, valueID = TRUE, doRob = FALSE, level = 0.95, scaled = TRUE, caliber = 9, dstTarget, conversion, unit = 'unit', alpha = 0.5, target) ## Default S3 method: drawGroup(xy, center = FALSE, xyTopLeft = TRUE, bb = FALSE, bbMin = FALSE, bbDiag = FALSE, minCirc = FALSE, minEll = FALSE, maxSpread = FALSE, meanDist = FALSE, confEll = FALSE, CEP = FALSE, ringID = FALSE, valueID = TRUE, doRob = FALSE, level = 0.95, scaled = TRUE, caliber = 9, dstTarget, conversion, unit = 'unit', alpha = 0.5, target)
drawGroup(xy, center = FALSE, xyTopLeft = TRUE, bb = FALSE, bbMin = FALSE, bbDiag = FALSE, minCirc = FALSE, minEll = FALSE, maxSpread = FALSE, meanDist = FALSE, confEll = FALSE, CEP = FALSE, ringID = FALSE, valueID = TRUE, doRob = FALSE, level = 0.95, scaled = TRUE, caliber = 9, dstTarget, conversion, unit = 'unit', alpha = 0.5, target) ## S3 method for class 'data.frame' drawGroup(xy, center = FALSE, xyTopLeft = TRUE, bb = FALSE, bbMin = FALSE, bbDiag = FALSE, minCirc = FALSE, minEll = FALSE, maxSpread = FALSE, meanDist = FALSE, confEll = FALSE, CEP = FALSE, ringID = FALSE, valueID = TRUE, doRob = FALSE, level = 0.95, scaled = TRUE, caliber = 9, dstTarget, conversion, unit = 'unit', alpha = 0.5, target) ## Default S3 method: drawGroup(xy, center = FALSE, xyTopLeft = TRUE, bb = FALSE, bbMin = FALSE, bbDiag = FALSE, minCirc = FALSE, minEll = FALSE, maxSpread = FALSE, meanDist = FALSE, confEll = FALSE, CEP = FALSE, ringID = FALSE, valueID = TRUE, doRob = FALSE, level = 0.95, scaled = TRUE, caliber = 9, dstTarget, conversion, unit = 'unit', alpha = 0.5, target)
xy |
either a numerical (n x 2)-matrix with the (x,y)-coordinates of n points (1 row of coordinates per point), or a data frame with either the variables |
center |
logical: center groups to mean (0,0) first? If variable |
xyTopLeft |
logical: is the origin of the absolute coordinate system in the top-left corner? This is the default for data exported by OnTarget PC/TDS. If an (n x 2)-matrix is supplied for |
bb |
logical: draw bounding box? |
bbMin |
logical: draw minimum-area bounding box? |
bbDiag |
logical: draw bounding box diagonal? |
minCirc |
logical: draw minimum enclosing circle? |
minEll |
logical: draw minimum enclosing ellipse? |
maxSpread |
logical: draw maximum spread? |
meanDist |
logical: draw circle with mean distance to group center? |
confEll |
logical: draw confidence ellipse with coverage |
CEP |
draw estimate of CEP circle with coverage |
ringID |
logical: identify and display the ring count for each shot? |
valueID |
logical: display numerical values of calculated measures in the diagram? |
doRob |
logical: use robust estimation of group center and confidence ellipse? |
scaled |
logical: draw bullet holes to scale? |
caliber |
a numerical value indicating the bullet diameter in mm. |
level |
a numerical vector giving the coverages of the confidence ellipses and CEPs. |
dstTarget |
a numerical value giving the distance to the target - used in MOA calculation. Acts as override if variable |
conversion |
how to convert the measurement unit for distance to target to that of the (x,y)-coordinates in MOA calculation. Acts as override if variables |
unit |
Measurement unit for the diagram. Defalt |
alpha |
a numerical value in [0,1] which controls the alpha blending for simulated transparency used to draw the bullet holes |
target |
a character string like 'ISSF_100m' indicating the target type to be drawn in the scatterplot. See |
Invisibly returns a list with the following components, all converted to unit
(if they were requested):
xy |
(x,y)-coordinates converted to |
ctr |
(x,y)-offset of group center relative to point of aim in |
bb |
bounding box as returned by |
bbMin |
minimum-area bounding box as returned by |
bbDiag |
length of diagonal of bounding box. |
bbMinDiag |
length of diagonal of minimum-area bounding box. |
minCirc |
minimum enclosing circle as returned by |
minEll |
minimum enclosing ellipse as returned by |
maxPairDist |
maximum pairwise distance between points (center-to-center, = maximum spread). |
meanDist |
mean distance to group center. |
confEll |
confidence ellipse with coverage |
CEP |
Rayleigh estimate for the circular error probable CEP with coverage |
target |
Definition of the selected target in original and converted measurement units. |
ringCount |
Simulated and maximum ring count as returned by |
getBoundingBox
,
getMinBBox
,
getMinCircle
,
getMinEllipse
,
getMaxPairDist
,
getDistToCtr
,
getConfEll
,
drawBox
,
drawBox2
,
drawCircle
,
drawEllipse
,
targets
,
drawTarget
,
simRingCount
,
covMcd
# draw group in MOA dg <- drawGroup(DFcciHV, xyTopLeft=TRUE, bb=TRUE, minCirc=TRUE, confEll=TRUE, maxSpread=TRUE, caliber=5.56, unit='MOA', dstTarget=100, conversion='yd2in', target='BDS9') # mininum enclosing circle in MOA dg$minCirc # show Grubbs-Patnaik CEP estimator for mulitple levels drawGroup(DF300BLKhl, CEP="GrubbsPatnaik", level=c(0.5, 0.9, 0.95), dstTarget=100, conversion="yd2in", caliber=7.62)
# draw group in MOA dg <- drawGroup(DFcciHV, xyTopLeft=TRUE, bb=TRUE, minCirc=TRUE, confEll=TRUE, maxSpread=TRUE, caliber=5.56, unit='MOA', dstTarget=100, conversion='yd2in', target='BDS9') # mininum enclosing circle in MOA dg$minCirc # show Grubbs-Patnaik CEP estimator for mulitple levels drawGroup(DF300BLKhl, CEP="GrubbsPatnaik", level=c(0.5, 0.9, 0.95), dstTarget=100, conversion="yd2in", caliber=7.62)
Draws a target pattern - either from the name of a pre-specified target type or from a supplied list defining the target.
drawTarget(x, unit, dstTarget, conversion, add = FALSE, cex = par('cex'))
drawTarget(x, unit, dstTarget, conversion, add = FALSE, cex = par('cex'))
x |
either a character value with the name of a target in |
unit |
the measurement unit that should be used in the plot. Possible values are |
dstTarget |
a numerical value with the distance to the target - used in MOA calculation. See |
conversion |
how to convert the measurement unit for distance to target to that of the (x,y)-coordinates - used in MOA calculation. Example |
add |
logical: add to existing plot or create new plot? |
cex |
numerical value specifying the magnification factor for plotting the ring numbers. |
Invisibly returns a list with (at least) the following components defining the target:
name |
target name. |
unitTarget |
measurement unit for ring diameters and radii. |
nRings |
number of rings. |
maxCount |
highest ring count for scoring. |
ringD10 |
diameter of ring number 10 (highest-valued ring). |
ringD10i |
diameter of sub-division of ring number 10 (Innenzehn). If target has no sub-division, equal to |
ringW |
width of the remaining rings number 9, 8, 7, ... |
cols |
|
colsTxt |
|
ringR |
|
unitConv |
measurement unit for |
ringD10u |
diameter of ring number 10 converted to |
ringD10iu |
diameter of sub-division of ring number 10 (Innenzehn) converted to |
ringWu |
width of the remaining rings number 9, 8, 7, ... converted to |
ringRu |
|
# draw ISSF 300m target in inch trgt <- drawTarget('ISSF_300m', unit='in') # target definition trgt
# draw ISSF 300m target in inch trgt <- drawTarget('ISSF_300m', unit='in') # target definition trgt
Estimates the approximate number of required groups for a given number of shots per group, confidence interval (CI) level and CI width - when using the Rayleigh sigma estimator based on (x,y)-coordinates, or a range statistic such as extreme spread, figure of merit, or the bounding box diagonal. The function may also be used to obtain the estimated CI width when the number of shots per group and the number of groups is given. This functions assumes a circular bivariate normal shot distribution with 0 mean.
efficiency(n, nGroups, CIlevel=0.95, CIwidth, stat=c("Rayleigh", "ES", "FoM", "D"))
efficiency(n, nGroups, CIlevel=0.95, CIwidth, stat=c("Rayleigh", "ES", "FoM", "D"))
n |
a vector of integers between 2 and 100. Number of shots in each group. |
nGroups |
integer between 1 and 10. Number of groups over which individually-measured statistics will be averaged - when given, |
CIlevel |
confidence level - coverage probability of the CI. |
CIwidth |
CI width as a fraction of the mean of the chosen statistic for given |
stat |
a character vector with elements |
Based on the lookup table DFdistr
with results form a Monte Carlo simulation. If the value of n
is not among those simulated (but is less than 100), a spline interpolation between the neighboring simulated values of the statistic's coefficient of variation is used.
The number of required groups is approximate as the calculation assumes a normal distribution for the mean statistic. Details for the calculation can be found under
http://ballistipedia.com/index.php?title=Range_Statistics
http://www.geoffrey-kolbe.com/articles/rimfire_accuracy/group_statistics.htm
http://ballistipedia.com/images/3/32/Sitton_1990.pdf
If package shiny
is installed, an interactive web app for this functionality can be run with runGUI("range")
.
When CIwidth
is given, a data frame with the estimated number of required groups and total shots to achieve the given CIlevel
.
n |
Number of shots per group. |
nGroupsReq |
Number of required groups - as calculated (fractional number). |
nGroupsReqCeil |
Number of required groups - rounded upwards to a whole number. |
nShotsReq |
Total number of required shots - using |
nShotsReqCeil |
Total number of required shots - using |
CIlevel |
The CI level |
CIwidth |
The CI width |
When nGroups
is given, a data frame with the estimated CI width required to achieve the desired CIlevel
.
n |
Number of shots per group. |
nGroups |
Number of groups that will be averaged over. |
nShots |
The total number of shots |
CIlevel |
The CI level |
CIwidth |
Required CI width as a fraction of the mean statistic. |
DFdistr
,
range2sigma
,
getRayParam
,
getMaxPairDist
,
getBoundingBox
# get required number of shots to achieve 90% CI with # a CI width of 20% of the mean (10% on either side) # using 10 shots per group and measuring extreme spread efficiency(n=10, CIlevel=0.9, CIwidth=0.2, stat="ES") # as above, but using Rayleigh sigma efficiency(n=10, CIlevel=0.9, CIwidth=0.2, stat="Rayleigh") # check that the result for ES is about right # -> 5% quantile with 10 groups is about 10% below the mean # -> 95% quantile with 10 groups is about 10% above the mean with(subset(DFdistr, (n == 10L) & (nGroups == 10L)), c(ES_Q050/ES_M, ES_Q950/ES_M)) # get achievable 90% CI width with 10 groups of 5 shots each # using extreme spread efficiency(n=5, nGroups=10, CIlevel=0.9, stat="ES")
# get required number of shots to achieve 90% CI with # a CI width of 20% of the mean (10% on either side) # using 10 shots per group and measuring extreme spread efficiency(n=10, CIlevel=0.9, CIwidth=0.2, stat="ES") # as above, but using Rayleigh sigma efficiency(n=10, CIlevel=0.9, CIwidth=0.2, stat="Rayleigh") # check that the result for ES is about right # -> 5% quantile with 10 groups is about 10% below the mean # -> 95% quantile with 10 groups is about 10% above the mean with(subset(DFdistr, (n == 10L) & (nGroups == 10L)), c(ES_Q050/ES_M, ES_Q950/ES_M)) # get achievable 90% CI width with 10 groups of 5 shots each # using extreme spread efficiency(n=5, nGroups=10, CIlevel=0.9, stat="ES")
Converts angular diameter (degree, radian, minute of angle MOA = arcminute, Shooter's MOA SMOA, milliradian mrad, NATO mil) to object size.
fromMOA(x, dst, conversion, type = c('deg', 'rad', 'MOA', 'SMOA', 'mrad', 'mil'))
fromMOA(x, dst, conversion, type = c('deg', 'rad', 'MOA', 'SMOA', 'mrad', 'mil'))
x |
a numerical vector of angles. |
dst |
a numerical vector of viewing distances. |
conversion |
how to convert the measurement unit for distance to target to that of the (x,y)-coordinates. Either a character vector indicating the conversion such as |
type |
type of angular diameter: |
1 MOA (minute of angle, arcmin) = 1/60 degree. Shooter's MOA = SMOA = Inches Per Hundred Yards IPHY. 1 inch at 100 yards = 1 SMOA. 1 milliradian = 1/1000 radian. 1 mil = 2*pi/6400 radian (NATO definition: the circle circumference is divided into 6400 mils). Details are given in the vignette, see vignette('shotGroups') .
If package shiny
is installed, an interactive web app for this functionality can be run with runGUI("angular")
.
A numerical vector with the object sizes. The measurement unit is determined by conversion
.
size <- seq(1, 20, by=5) # inch dst <- 100 # yard fromMOA(size, dst=dst, conversion='yd2in', type='MOA') # this should return objSize MOA <- getMOA(size, dst=dst, conversion='yd2in', type='MOA') fromMOA(MOA, dst=dst, conversion='yd2in', type='MOA') # SMOA fromMOA(c(1, 2, 5), dst=100, conversion='yd2in', type='SMOA') # milliradian fromMOA(c(1, 2, 5), dst=100, conversion='m2mm', type='mrad')
size <- seq(1, 20, by=5) # inch dst <- 100 # yard fromMOA(size, dst=dst, conversion='yd2in', type='MOA') # this should return objSize MOA <- getMOA(size, dst=dst, conversion='yd2in', type='MOA') fromMOA(MOA, dst=dst, conversion='yd2in', type='MOA') # SMOA fromMOA(c(1, 2, 5), dst=100, conversion='yd2in', type='SMOA') # milliradian fromMOA(c(1, 2, 5), dst=100, conversion='m2mm', type='mrad')
Calculates the vertices of the (axis-parallel) bounding box given a set of 2D-coordinates.
getBoundingBox(xy) ## S3 method for class 'data.frame' getBoundingBox(xy) ## Default S3 method: getBoundingBox(xy)
getBoundingBox(xy) ## S3 method for class 'data.frame' getBoundingBox(xy) ## Default S3 method: getBoundingBox(xy)
xy |
either a numerical (n x 2)-matrix with the (x,y)-coordinates of n points (1 row of coordinates per point), or a data frame with either the variables |
No coordinate transforms are done (unlike in groupLocation
, groupShape
, groupSpread
), i.e., origin is not assumed to be in top-left corner, and points are not taken relative to point of aim.
A list with the following information about the bounding box:
pts |
a numerical 4-vector giving the coordinates |
width |
width of the box. |
height |
height of the box. |
FoM |
figure of merit, i.e., the average side length of the box: ( |
diag |
length of box diagonal. |
drawBox
,
getMinBBox
,
getMinCircle
# coordinates given by a suitable data frame bb <- getBoundingBox(DFsavage) # draw points and bounding box plot(point.y ~ point.x, data=DFsavage, asp=1, pch=16) drawBox(bb, fg='blue', colCtr='blue', pch=4, cex=2) bb$FoM # figure of merit # coordinates given by a matrix ## Not run: xy <- matrix(round(rnorm(20, 100, 15), 1), ncol=2) getBoundingBox(xy) ## End(Not run)
# coordinates given by a suitable data frame bb <- getBoundingBox(DFsavage) # draw points and bounding box plot(point.y ~ point.x, data=DFsavage, asp=1, pch=16) drawBox(bb, fg='blue', colCtr='blue', pch=4, cex=2) bb$FoM # figure of merit # coordinates given by a matrix ## Not run: xy <- matrix(round(rnorm(20, 100, 15), 1), ncol=2) getBoundingBox(xy) ## End(Not run)
Estimates the Circular Error Probable (CEP) or the Spherical Error Probable (SEP). CEP/SEP is defined as the radius of the circle/sphere around the point of aim such that it contains a certain fraction of points of impact, e.g., 50% or 90%.
getCEP(xy, CEPlevel=0.5, dstTarget, conversion, center = FALSE, accuracy = FALSE, type = 'CorrNormal', doRob = FALSE) ## S3 method for class 'data.frame' getCEP(xy, CEPlevel=0.5, dstTarget, conversion, center = FALSE, accuracy = FALSE, type = 'CorrNormal', doRob = FALSE) ## Default S3 method: getCEP(xy, CEPlevel=0.5, dstTarget, conversion, center = FALSE, accuracy = FALSE, type = 'CorrNormal', doRob = FALSE)
getCEP(xy, CEPlevel=0.5, dstTarget, conversion, center = FALSE, accuracy = FALSE, type = 'CorrNormal', doRob = FALSE) ## S3 method for class 'data.frame' getCEP(xy, CEPlevel=0.5, dstTarget, conversion, center = FALSE, accuracy = FALSE, type = 'CorrNormal', doRob = FALSE) ## Default S3 method: getCEP(xy, CEPlevel=0.5, dstTarget, conversion, center = FALSE, accuracy = FALSE, type = 'CorrNormal', doRob = FALSE)
xy |
either a numerical (n x p)-matrix with the coordinates of n points (1 row of p coordinates per point), or a data frame with either the variables |
CEPlevel |
a numerical vector with the coverage values for the CEP/SEP. |
dstTarget |
a numerical value giving the distance to the target - used in MOA calculation. Acts as override if variable |
conversion |
how to convert the measurement unit for distance to target to that of the (x,y)-coordinates in MOA calculation. Acts as override if variables |
center |
logical: center groups to mean (0,0) first? If variable |
accuracy |
logical: take systematic location bias into account? See details. |
type |
string vector indicating which CEP/SEP estimate to report. Possible values are |
doRob |
logical: use robust estimation of center and covariance matrix as basis for estimators? |
For accuracy=FALSE
(default), the reported CEP/SEP estimates do not take into account accuracy, i.e., any systematic location bias. The data is then first centered on the empirical group mean, assumed to coincide with the point of aim. The resulting CEP/SEP-MPI (around Mean Point of Impact) is a pure precision (spread) measure. Set accuracy=TRUE
to incorporate systematic accuracy bias such that the point of aim is in the origin 0, possibly offset from the true group center.
CorrNormal
: For accuracy=FALSE
and two-dimensional data, this estimate is based on the correlated bivariate normal distribution re-written in polar coordinates (radius and angle) (see Hoyt
). For accuracy=TRUE
or three-dimensional data, it is based on the (offset) circle/sphere probabilities for the correlated multivariate normal distribution (DiDonato & Jarnagin, 1961; DiDonato, 1981, see qmvnEll
). This estimate is available for all probability levels.
GrubbsPearson
: The Grubbs-Pearson estimate (Grubbs, 1964) is based on the Pearson three-moment central chi^2-approximation of the true cumulative distribution function of radial error. The eigenvalues of the covariance matrix of shot-coordinates are used as variance estimates since they are the variances of the principal components (the PCA-rotated = decorrelated data). This estimate is available for all probability levels, and generalizes to three dimensions.
GrubbsPatnaik
: The Grubbs-Patnaik estimate (Grubbs, 1964) differs from the Grubbs-Pearson estimate insofar as it is based on the Patnaik two-moment central chi^2-approximation of the true cumulative distribution function of radial error.
GrubbsLiu
: The Grubbs-Liu estimate was not proposed by Grubbs but follows the same principle as his original estimates. It differs from them insofar as it is based on the Liu-Tang-Zhang four-moment non-central chi^2-approximation of the true cumulative distribution function of radial error. For accuracy=FALSE
, it is identical to GrubbsPearson
.
Rayleigh
: For accuracy=FALSE
and two-dimensional data, this estimate uses the Rayleigh distribution (see getRayParam
). It is valid for uncorrelated bivariate normal coordinates with equal variances. This estimate is available for all probability levels. For accuracy=FALSE
and three-dimensional data, the Maxwell-Boltzmann distribution is used (see getRayParam
). For accuracy=TRUE
and two-dimensional data, the estimate uses the Rice distribution (see getRiceParam
). For accuracy=TRUE
and three-dimensional data, it is based on the offset sphere probabilities for the multivariate normal distribution set to have equal variances (see qmvnEll
).
Krempasky
: The Krempasky estimate (Krempasky, 2003) is based on a nearly exact closed-form solution for the 50% quantile of the radial error for the correlated bivariate normal distribution with 0 mean. It requires estimating the covariance matrix and can only be reported for probability 0.5 with accuracy=FALSE
. It does not generalize to three dimensions.
Ignani
: The Ignani estimate (Ignani, 2010) is based on a polynomial approximation for some quantiles of the radial error for the correlated bivariate normal distribution with 0 mean. It requires estimating the covariance matrix and can only be reported for probabilities 0.5, 0.9, 0.95, 0.99 with accuracy=FALSE
. It generalizes to three dimensions.
RMSE
: For accuracy=FALSE
, this estimator is the RMSE estimator often described in the GPS literature (van Diggelen, 2007) when using centered data for calculating RMSE (square root of the mean squared error). It is very similar to the Rayleigh
estimator. For accuracy=TRUE
, this the RMSE estimator often described in the GPS literature when using the original, non-centered data for calculating RMSE. It is similar to the Rayleigh
estimator only when bias is small, but becomes seriously wrong otherwise. It is available for all probability levels, and generalizes to three dimensions.
Ethridge
: The Ethridge estimate (Ethridge, 1983; Puhek, 1992) is not based on the assumption of multivariate normality of coordinates but uses a robust unbiased estimator for the median radius (Hogg, 1967). It can only be reported for probability 0.5 but generalizes to three dimensions.
RAND
: The modified RAND R-234 estimate (RAND, 1952; Pesapane & Irvine, 1977; Puhek 1992) is a weighted sum of the square root of the eigenvalues of the covariance matrix of shot coordinates (the standard deviations of the data that is first de-correlated through rotation). It can only be reported for probability 0.5 and does not generalize to three dimensions.
Valstar
: Very similar to the RAND R-234 estimate with accuracy=FALSE
except for very elliptical distributions but with a different bias correction with accuracy=TRUE
. It can only be reported for probability 0.5 and does not generalize to three dimensions.
Estimators based on the normal distribution use the plug-in method (Blischke & Halpin, 1966), i.e., they substitute the true covariance matrix and mean vector with those estimated from the data. They are thus strictly valid only for the asymptotic distribution, while the finite sample distribution may differ somewhat.
If package shiny
is installed, an interactive web app for this functionality can be run with runGUI("hitprob")
.
A list with the (chosen) CEP/SEP estimates and supplementary information on the distribution shape.
CEP |
a numerical matrix with the chosen CEP/SEP estimates at the indicated |
ellShape |
a numerical vector with the aspect ratio of the ellipse (the square root of condition index |
ctr |
group center |
Blischke W. R. and Halpin, A. H. (1966). Asymptotic properties of some estimators of quantiles of circular error. Journal of the American Statistical Association, 61 (315), 618-632.
DiDonato, A. R. (1988). Integration of the trivariate normal distribution over an offset spehere and an inverse problem (NSWC TR 87-27). Dahlgren, VA: U.S. Naval Surface Weapons Center Dahlgren Division.
DiDonato, A. R., & Jarnagin, M. P. (1961). Integration of the general bivariate Gaussian distribution over an offset circle. Mathematics of Computation, 15 (76), 375-382.
Grubbs, F. E. (1964). Approximate circular and noncircular offset probabilities of hitting. Operations Research, 12(1), 51-62.
Hogg, R. V. (1967). Some observations on robust estimation. Journal of the American Statistical Association, 62 (320), 1179-1186.
Ignani, B. (2010). Determination of Circular and Spherical Position-Error Bounds in System Performance Analysis. Journal of Guidance, Control, and Dynamics, 33 (4), 1301-1304.
Krempasky, J. J. (2003). CEP equation exact to the fourth order. Navigation: Journal of The Institute of Navigation, 50 (3), 143-149.
Liu, H., Tang, Y., & Zhang, H. H. (2009). A new chi-square approximation to the distribution of non-negative definite quadratic forms in non-central normal variables. Computational Statistics & Data Analysis, 53(4), 853-856.
Pesapane, J., & Irvine, R. B. (1977). Derivation of CEP formula to approximate RAND-234 tables. Offut AFB, NE: Ballistic Missile Evaluation, HQ SAC.
Puhek, P. (1992). Sensitivity analysis of circular error probable approximation techniques (AFIT/GOR/ENS/92M-23). Wright-Patterson AFB, OH: Air Force Institute of Technology.
RAND Corporation. (1952). Offset circle probabilities (RAND-234). Santa Monica, CA: RAND Corporation.
Singh, H. P. 1992. Estimation of Circular Probable Error. The Indian Journal of Statistics, Series B 5(3), 289-305.
van Diggelen, F. 2007. Update: GNSS Accuracy: Lies, Damn Lies, and Statistics. GPS World.
Rayleigh
,
Maxwell
,
Hoyt
,
Rice
,
mvnEll
,
getHoytParam
,
getRayParam
,
getRiceParam
,
getConfEll
,
getHitProb
,
covMcd
# coordinates given by a suitable data frame (cep <- getCEP(DFtalon, CEPlevel=0.5, accuracy=FALSE, dstTarget=10, conversion='m2mm', type=c('CorrNormal', 'GrubbsPatnaik', 'Rayleigh'))) # plot points, centers, and circles indicating 50%-CEP estimates plot(point.y ~ point.x, data=DFtalon, asp=1, pch=16) drawCircle(cep$ctr, cep$CEP$CEP0.5['unit', 'CorrNormal'], fg='red') drawCircle(cep$ctr, cep$CEP$CEP0.5['unit', 'GrubbsPatnaik'], fg='green3') drawCircle(cep$ctr, cep$CEP$CEP0.5['unit', 'Rayleigh'], fg='blue') points(cep$ctr[1], cep$ctr[2], pch=4, col='gray50', cex=2, lwd=2) legend(x='bottomleft', legend=c('Grubbs 50', 'Corr Normal 50', 'Rayleigh 50', 'center'), col=c('red', 'green3', 'blue', 'gray50'), lwd=2, lty=c(1, 1, 1, NA), pch=c(NA, NA, NA, 4), bg='white') # calculate actual coverage percentage of 50% CEP estimates dists <- getDistToCtr(DFtalon) # distances to center # extract CEP radius for all estimates CEPr <- cep$CEP$CEP0.5['unit', ] # percentage of points in circle with radius = CEP 100 * sapply(CEPr, function(x) sum(dists <= x)) / length(dists) # coordinates given by a matrix ## Not run: xy <- matrix(round(rnorm(100, 0, 5), 2), ncol=2) getCEP(xy, accuracy=FALSE, dstTarget=25, conversion='m2cm', type=c('Grubbs', 'CorrNormal', 'Rayleigh')) ## End(Not run)
# coordinates given by a suitable data frame (cep <- getCEP(DFtalon, CEPlevel=0.5, accuracy=FALSE, dstTarget=10, conversion='m2mm', type=c('CorrNormal', 'GrubbsPatnaik', 'Rayleigh'))) # plot points, centers, and circles indicating 50%-CEP estimates plot(point.y ~ point.x, data=DFtalon, asp=1, pch=16) drawCircle(cep$ctr, cep$CEP$CEP0.5['unit', 'CorrNormal'], fg='red') drawCircle(cep$ctr, cep$CEP$CEP0.5['unit', 'GrubbsPatnaik'], fg='green3') drawCircle(cep$ctr, cep$CEP$CEP0.5['unit', 'Rayleigh'], fg='blue') points(cep$ctr[1], cep$ctr[2], pch=4, col='gray50', cex=2, lwd=2) legend(x='bottomleft', legend=c('Grubbs 50', 'Corr Normal 50', 'Rayleigh 50', 'center'), col=c('red', 'green3', 'blue', 'gray50'), lwd=2, lty=c(1, 1, 1, NA), pch=c(NA, NA, NA, 4), bg='white') # calculate actual coverage percentage of 50% CEP estimates dists <- getDistToCtr(DFtalon) # distances to center # extract CEP radius for all estimates CEPr <- cep$CEP$CEP0.5['unit', ] # percentage of points in circle with radius = CEP 100 * sapply(CEPr, function(x) sum(dists <= x)) / length(dists) # coordinates given by a matrix ## Not run: xy <- matrix(round(rnorm(100, 0, 5), 2), ncol=2) getCEP(xy, accuracy=FALSE, dstTarget=25, conversion='m2cm', type=c('Grubbs', 'CorrNormal', 'Rayleigh')) ## End(Not run)
Calculates the confidence ellipse for the true mean of shot coordinates under the assumption of multivariate normality. Also includes the ellipse based on a robust estimate for the covariance matrix of the shot coordinates.
getConfEll(xy, level = 0.5, dstTarget, conversion, center = FALSE, doRob=TRUE) ## S3 method for class 'data.frame' getConfEll(xy, level = 0.5, dstTarget, conversion, center = FALSE, doRob=TRUE) ## Default S3 method: getConfEll(xy, level = 0.5, dstTarget, conversion, center = FALSE, doRob=TRUE)
getConfEll(xy, level = 0.5, dstTarget, conversion, center = FALSE, doRob=TRUE) ## S3 method for class 'data.frame' getConfEll(xy, level = 0.5, dstTarget, conversion, center = FALSE, doRob=TRUE) ## Default S3 method: getConfEll(xy, level = 0.5, dstTarget, conversion, center = FALSE, doRob=TRUE)
xy |
Shot coordinates of n points: either a numerical (n x p)-matrix (1 row of p coordinates per point), or a data frame with either the variables |
level |
a numerical value with the coverage for the confidence ellipse. |
dstTarget |
a numerical value giving the distance to the target - used in MOA calculation. Acts as override if variable |
conversion |
how to convert the measurement unit for distance to target to that of the (x,y)-coordinates in MOA calculation. Acts as override if variables |
center |
logical: center groups to mean (0,0) first? If variable |
doRob |
logical: should robust covariance matrix estimate be used as well? |
No coordinate transforms are done (unlike in groupLocation
, groupShape
, groupSpread
), i.e., origin is not assumed to be in top-left corner, and points are not taken relative to point of aim.
Robust estimate for the covariance matrix of coordinates is from covMcd
using the MCD algorithm. See getCEP
for estimates of the circular/spherical error probable.
A list with the confidence ellipse measures.
ctr |
coordinates group center. |
ctrRob |
coordinates robust estimate of group center. |
cov |
covariance matrix. |
covRob |
robust estimate of covariance matrix. |
size |
a numerical matrix with the lengths of the semi-axes of the ellipse (in original measurement units, MOA, SMOA, milliradian). |
sizeRob |
a numerical matrix with the lengths of the semi-axes of the ellipse based on a robust estimate for the covariance matrix of shot coordinates (in original measurement units, MOA, SMOA, milliradian). |
shape |
a numerical vector with the angle, the aspect ratio of the ellipse (square root of condition index |
shapeRob |
a numerical vector with the aspect ratio and the flattening of the ellipse as well as the trace and determinant based on a robust estimate for the covariance matrix of shot coordinates. |
magFac |
magnification factor used to turn the error ellipse into the confidence ellipse as determined by the F(p, n-1)-distribution. |
# coordinates given by a suitable data frame (ce <- getConfEll(DFsavage, level=0.5, dstTarget=100, conversion='yd2in')) # plot points, center, parametric confidence # ellipse, and its axes plot(point.y ~ point.x, data=DFsavage, asp=1, pch=16) drawEllipse(ce, axes=TRUE, fg='blue', colCtr='blue', lwd=2, pch=4, cex=2) # coordinates given by a matrix ## Not run: xy <- matrix(round(rnorm(100, 0, 5), 2), ncol=2) getConfEll(xy, level=0.5, dstTarget=25, conversion='m2cm') ## End(Not run)
# coordinates given by a suitable data frame (ce <- getConfEll(DFsavage, level=0.5, dstTarget=100, conversion='yd2in')) # plot points, center, parametric confidence # ellipse, and its axes plot(point.y ~ point.x, data=DFsavage, asp=1, pch=16) drawEllipse(ce, axes=TRUE, fg='blue', colCtr='blue', lwd=2, pch=4, cex=2) # coordinates given by a matrix ## Not run: xy <- matrix(round(rnorm(100, 0, 5), 2), ncol=2) getConfEll(xy, level=0.5, dstTarget=25, conversion='m2cm') ## End(Not run)
Calculates the distance to an object based on the object's absolute and angular size.
getDistance(x, angular, conversion, type = c('deg', 'rad', 'MOA', 'SMOA', 'mrad', 'mil'))
getDistance(x, angular, conversion, type = c('deg', 'rad', 'MOA', 'SMOA', 'mrad', 'mil'))
x |
a numerical vector of absolute object sizes. |
angular |
a numerical vector of angular object sizes. |
conversion |
how to convert the measurement unit for the returned distance to object to that of given absolute object size. Either a character vector indicating the conversion such as |
type |
type of angular measure used in |
1 MOA (minute of angle, arcmin) = 1/60 degree. Shooter's MOA = SMOA = Inches Per Hundred Yards IPHY. 1 inch at 100 yards = 1 SMOA. 1 milliradian = 1/1000 radian. 1 mil = 2*pi/6400 radian (NATO definition: the circle circumference is divided into 6400 mils). Details are given in the vignette, see vignette('shotGroups')
A numerical vector with the distance values.
size <- seq(1, 20, by=5) # inch dst <- 100 # yard # get angular size in MOA from absolute size angular <- getMOA(size, dst=dst, conversion='yd2in', type='MOA') # this should return dst throughout getDistance(size, angular=angular, conversion='yd2in', type='MOA')
size <- seq(1, 20, by=5) # inch dst <- 100 # yard # get angular size in MOA from absolute size angular <- getMOA(size, dst=dst, conversion='yd2in', type='MOA') # this should return dst throughout getDistance(size, angular=angular, conversion='yd2in', type='MOA')
Calculates the distances of a set of points to their center.
getDistToCtr(xy) ## S3 method for class 'data.frame' getDistToCtr(xy) ## Default S3 method: getDistToCtr(xy)
getDistToCtr(xy) ## S3 method for class 'data.frame' getDistToCtr(xy) ## Default S3 method: getDistToCtr(xy)
xy |
either a numerical (n x p)-matrix with the coordinates of n points in p-dimensional space (1 row of coordinates per point), or a data frame with either the variables |
A numerical vector with the distances from each point to the center of the set.
# coordinates given by a suitable data frame getDistToCtr(DFtalon) # coordinates given by a matrix ## Not run: xy <- matrix(round(rnorm(20, 100, 15), 1), ncol=2) getDistToCtr(xy) ## End(Not run)
# coordinates given by a suitable data frame getDistToCtr(DFtalon) # coordinates given by a matrix ## Not run: xy <- matrix(round(rnorm(20, 100, 15), 1), ncol=2) getDistToCtr(xy) ## End(Not run)
Calculates the hit probability within a circular or spherical region for a given group of two- or three-dimensional coordinates.
getHitProb(xy, r=1, unit = 'unit', dstTarget, conversion, center = FALSE, accuracy = FALSE, type = 'CorrNormal', doRob = FALSE) ## S3 method for class 'data.frame' getHitProb(xy, r=1, unit = 'unit', dstTarget, conversion, center = FALSE, accuracy = FALSE, type = 'CorrNormal', doRob = FALSE) ## Default S3 method: getHitProb(xy, r=1, unit = 'unit', dstTarget, conversion, center = FALSE, accuracy = FALSE, type = 'CorrNormal', doRob = FALSE)
getHitProb(xy, r=1, unit = 'unit', dstTarget, conversion, center = FALSE, accuracy = FALSE, type = 'CorrNormal', doRob = FALSE) ## S3 method for class 'data.frame' getHitProb(xy, r=1, unit = 'unit', dstTarget, conversion, center = FALSE, accuracy = FALSE, type = 'CorrNormal', doRob = FALSE) ## Default S3 method: getHitProb(xy, r=1, unit = 'unit', dstTarget, conversion, center = FALSE, accuracy = FALSE, type = 'CorrNormal', doRob = FALSE)
xy |
either a numerical (n x p)-matrix with the coordinates of n points (1 row of p coordinates per point), or a data frame with either the variables |
r |
a numerical vector with the radius values for the circle/sphere that defines the region for which the probability should be calculated. |
unit |
Measurement unit for radius |
dstTarget |
a numerical value giving the distance to the target - used in MOA calculation. Acts as override if variable |
conversion |
how to convert the measurement unit for distance to target to that of the (x,y)-coordinates in MOA calculation. Acts as override if variables |
center |
logical: center groups to mean (0,0) first? If variable |
accuracy |
logical: take systematic location bias into account? See details. |
type |
string vector indicating which estimation method to use. Possible values are |
doRob |
logical: use robust estimation of center and covariance matrix as basis for estimates? For Rayleigh only available when |
The estimated hit probability is the same as the estimated fraction of shots with a distance to their group center of at most r
.
For accuracy=FALSE
(default), the estimated hit probability does not take into account accuracy, i.e., any systematic location bias. The data is then first centered on the empirical group mean, assumed to coincide with the point of aim. Set accuracy=TRUE
to incorporate systematic accuracy bias such that the point of aim is in the origin 0, possibly offset from the true group center.
CorrNormal
: For accuracy=FALSE
and two-dimensional data, this estimate is based on the quantile function of the correlated bivariate normal distribution re-written in polar coordinates (radius and angle) (see Hoyt
). For accuracy=TRUE
or three-dimensional data, it is based on the (offset) circle/sphere probabilities for the correlated multivariate normal distribution (DiDonato & Jarnagin, 1961; DiDonato, 1981, see pmvnEll
).
GrubbsPearson
: The Grubbs-Pearson estimate (Grubbs, 1964) is based on the Pearson three-moment central chi^2-approximation of the true cumulative distribution function of radial error. The eigenvalues of the covariance matrix of shot-coordinates are used as variance estimates since they are the variances of the principal components (the PCA-rotated = decorrelated data).
GrubbsPatnaik
: The Grubbs-Patnaik estimate (Grubbs, 1964) differs from the Grubbs-Pearson estimate insofar as it is based on the Patnaik two-moment central chi^2-approximation of the true cumulative distribution function of radial error.
GrubbsLiu
: The Grubbs-Liu estimate was not proposed by Grubbs but follows the same principle as his original estimates. It differs from them insofar as it is based on the Liu-Tang-Zhang four-moment non-central chi^2-approximation of the true cumulative distribution function of radial error. For accuracy=FALSE
, it is identical to GrubbsPearson
.
Rayleigh
: For accuracy=FALSE
and two-dimensional data, this estimate uses the Rayleigh distribution (see getRayParam
). It is valid for uncorrelated bivariate normal coordinates with equal variances. This estimate is available for all probability levels. For accuracy=FALSE
and three-dimensional data, the Maxwell-Boltzmann distribution is used (see getRayParam
). For accuracy=TRUE
and two-dimensional data, the estimate uses the Rice distribution (see getRiceParam
). For accuracy=TRUE
and three-dimensional data, it is based on the offset sphere probabilities for the multivariate normal distribution set to have equal variances (see qmvnEll
).
If package shiny
is installed, an interactive web app for this functionality can be run with runGUI("hitprob")
.
A vector with the (chosen) hit-probability estimates. For more than one r
and more than one type
, a matrix.
DiDonato, A. R. (1988). Integration of the trivariate normal distribution over an offset spehere and an inverse problem (NSWC TR 87-27). Dahlgren, VA: U.S. Naval Surface Weapons Center Dahlgren Division.
DiDonato, A. R., & Jarnagin, M. P. (1961). Integration of the general bivariate Gaussian distribution over an offset circle. Mathematics of Computation, 15 (76), 375-382.
Grubbs, F. E. (1964). Approximate circular and noncircular offset probabilities of hitting. Operations Research, 12(1), 51-62.
Liu, H., Tang, Y., & Zhang, H. H. (2009). A new chi-square approximation to the distribution of non-negative definite quadratic forms in non-central normal variables. Computational Statistics & Data Analysis, 53(4), 853-856.
Singh, H. P. 1992. Estimation of Circular Probable Error. The Indian Journal of Statistics, Series B 5(3), 289-305.
Rayleigh
,
Maxwell
,
Hoyt
,
mvnEll
,
getHoytParam
,
getRayParam
,
getCEP
,
getConfEll
,
covMcd
# coordinates given by a suitable data frame # estimated fraction of shots within a circle with radius # 1 and 1.5 MOA. getHitProb(DFscar17, r=c(1, 1.5), unit='MOA', accuracy=FALSE, dstTarget=100, conversion='yd2in', type=c('CorrNormal', 'GrubbsPatnaik')) # coordinates given by a matrix ## Not run: xy <- matrix(round(rnorm(100, 0, 5), 2), ncol=2) getHitProb(xy, r=c(2, 2.5), unit='MOA', accuracy=FALSE, dstTarget=100, conversion='yd2in', type=c('CorrNormal', 'GrubbsPatnaik')) ## End(Not run)
# coordinates given by a suitable data frame # estimated fraction of shots within a circle with radius # 1 and 1.5 MOA. getHitProb(DFscar17, r=c(1, 1.5), unit='MOA', accuracy=FALSE, dstTarget=100, conversion='yd2in', type=c('CorrNormal', 'GrubbsPatnaik')) # coordinates given by a matrix ## Not run: xy <- matrix(round(rnorm(100, 0, 5), 2), ncol=2) getHitProb(xy, r=c(2, 2.5), unit='MOA', accuracy=FALSE, dstTarget=100, conversion='yd2in', type=c('CorrNormal', 'GrubbsPatnaik')) ## End(Not run)
Determines the Hoyt distribution's shape parameter q and scale parameter omega from the eigenvalues of a (2 x 2)-covariance matrix.
getHoytParam(x) ## S3 method for class 'matrix' getHoytParam(x) ## S3 method for class 'list' getHoytParam(x) ## S3 method for class 'data.frame' getHoytParam(x) ## Default S3 method: getHoytParam(x)
getHoytParam(x) ## S3 method for class 'matrix' getHoytParam(x) ## S3 method for class 'list' getHoytParam(x) ## S3 method for class 'data.frame' getHoytParam(x) ## Default S3 method: getHoytParam(x)
x |
one of the following: a (2 x 2)-covariance matrix, a list of (2 x 2)-covariance matrices, a data frame with either the variables |
The parameters q
and omega
derive from the eigenvalues ev1, ev2 of the covariance matrix of the bivariate normal distribution as follows: q = 1 / sqrt(((ev1+ev2)/ev2) - 1)
and omega = ev1 + ev2
.
If x
is a data frame, its sample covariance matrix is used to estimate the eigenvalues. Note that the Hoyt distribution is only approximately valid for large samples if estimated parameters are used.
A list with the following components:
q |
A vector with values of the shape parameter |
omega |
A vector with values of the scale parameter |
Hoyt, R. S. (1947). Probability functions for the modulus and angle of the normal complex variate. Bell System Technical Journal, 26(2), 318-359.
https://reference.wolfram.com/language/ref/HoytDistribution.html
## q and omega based on coordinates in a data frame getHoytParam(DFscar17) ## q and omega based on a covariance matrix cm1 <- cbind(c(8, 0), c(0, 2)) getHoytParam(cm1) ## q and omega based on a list of covariance matrices cm2 <- cbind(c(6, 0), c(0, 4)) cmL <- list(cm1, cm2) getHoytParam(cmL) ## q and omega based on eigenvalues ev <- eigen(cm1)$values getHoytParam(cm1)
## q and omega based on coordinates in a data frame getHoytParam(DFscar17) ## q and omega based on a covariance matrix cm1 <- cbind(c(8, 0), c(0, 2)) getHoytParam(cm1) ## q and omega based on a list of covariance matrices cm2 <- cbind(c(6, 0), c(0, 4)) cmL <- list(cm1, cm2) getHoytParam(cmL) ## q and omega based on eigenvalues ev <- eigen(cm1)$values getHoytParam(cm1)
Estimates the Kuchnost precision measure. The maximum distance to the group center after removing outliers.
getKuchnost(xy, dstTarget, conversion, center = FALSE, doRob = FALSE, strict = FALSE) ## S3 method for class 'data.frame' getKuchnost(xy, dstTarget, conversion, center = FALSE, doRob = FALSE, strict = FALSE) ## Default S3 method: getKuchnost(xy, dstTarget, conversion, center = FALSE, doRob = FALSE, strict = FALSE)
getKuchnost(xy, dstTarget, conversion, center = FALSE, doRob = FALSE, strict = FALSE) ## S3 method for class 'data.frame' getKuchnost(xy, dstTarget, conversion, center = FALSE, doRob = FALSE, strict = FALSE) ## Default S3 method: getKuchnost(xy, dstTarget, conversion, center = FALSE, doRob = FALSE, strict = FALSE)
xy |
either a numerical (n x p)-matrix with the coordinates of n points (1 row of p coordinates per point), or a data frame with either the variables |
dstTarget |
a numerical value giving the distance to the target - used in MOA calculation. Acts as override if variable |
conversion |
how to convert the measurement unit for distance to target to that of the (x,y)-coordinates in MOA calculation. Acts as override if variables |
center |
logical: center groups to mean (0,0) first? If variable |
doRob |
logical: use robust estimation of center and covariance matrix as basis for estimators? |
strict |
logical: enable check that |
An outlier is defined as a shot that is at least 2.5 times further away from the group center defined by all remaining shots compared to the maximum distance to center of those shots themselves.
A list with 3 components.
Kuchnost |
The Kuchnost precision measure. |
outlier |
Indices of outliers, if any. |
ctr |
group center after removing outliers |
https://github.com/lstange/mcgs
getKuchnost(DF300BLK)
getKuchnost(DF300BLK)
Calculates the maximum of pairwise distances between points given a set of coordinates.
getMaxPairDist(xy) ## S3 method for class 'data.frame' getMaxPairDist(xy) ## Default S3 method: getMaxPairDist(xy)
getMaxPairDist(xy) ## S3 method for class 'data.frame' getMaxPairDist(xy) ## Default S3 method: getMaxPairDist(xy)
xy |
either a numerical (n x p)-matrix with the coordinates of n points in p-dimensional space (1 row of coordinates per point), or a data frame with either the variables |
A list with the following components
d |
numerical value with the maximum pairwise distance between points. |
idx |
a vector with two entries giving the row indices of the points that are farthest apart. |
# coordinates given by a suitable data frame (maxPD <- getMaxPairDist(DFsavage)) # plot points and point pair with maximum distance plot(point.y ~ point.x, data=DFsavage, asp=1, pch=16) x0 <- DFsavage$point.x[maxPD$idx[1]] # 1st point x y0 <- DFsavage$point.y[maxPD$idx[1]] # 1st point y x1 <- DFsavage$point.x[maxPD$idx[2]] # 2nd point x y1 <- DFsavage$point.y[maxPD$idx[2]] # 2nd point y segments(x0, y0, x1, y1, col="green3", lwd=2) # coordinates given by a matrix ## Not run: xy <- matrix(round(rnorm(20, 100, 15), 1), ncol=2) getMaxPairDist(xy) ## End(Not run)
# coordinates given by a suitable data frame (maxPD <- getMaxPairDist(DFsavage)) # plot points and point pair with maximum distance plot(point.y ~ point.x, data=DFsavage, asp=1, pch=16) x0 <- DFsavage$point.x[maxPD$idx[1]] # 1st point x y0 <- DFsavage$point.y[maxPD$idx[1]] # 1st point y x1 <- DFsavage$point.x[maxPD$idx[2]] # 2nd point x y1 <- DFsavage$point.y[maxPD$idx[2]] # 2nd point y segments(x0, y0, x1, y1, col="green3", lwd=2) # coordinates given by a matrix ## Not run: xy <- matrix(round(rnorm(20, 100, 15), 1), ncol=2) getMaxPairDist(xy) ## End(Not run)
Calculates the vertices of the minimum-area, possibly oriented bounding box given a set of 2D-coordinates.
getMinBBox(xy) ## S3 method for class 'data.frame' getMinBBox(xy) ## Default S3 method: getMinBBox(xy)
getMinBBox(xy) ## S3 method for class 'data.frame' getMinBBox(xy) ## Default S3 method: getMinBBox(xy)
xy |
either a numerical (n x 2)-matrix with the (x,y)-coordinates of n >= 2 points (1 row of coordinates per point), or a data frame with either the variables |
No coordinate transforms are done (unlike in groupLocation
, groupShape
, groupSpread
), i.e., origin is not assumed to be in top-left corner, and points are not taken relative to point of aim.
Uses the rotating calipers algorithm (Toussaint, 1983).
A list with the following information about the minimum-area bounding box:
pts |
a (4 x 2)-matrix containing the coordinates of the (ordered) vertices. |
width |
width of the box. |
height |
height of the box. |
FoM |
figure of merit, i.e., the average side length of the box: ( |
diag |
length of box diagonal. |
angle |
orientation of the box' longer edge pointing up as returned by |
Computational Geometry Algorithms Library. 2021. CGAL Chapter 65: Bounding Volumes. https://doc.cgal.org/Manual/latest/doc_html/cgal_manual/Bounding_volumes/Chapter_main.html Toussaint, G. T. 1983. Solving geometric problems with the rotating calipers. In: Proceedings of the 1983 IEEE MELECON. Athens, Greece: IEEE Computer Society.
drawBox2
,
getBoundingBox
,
getMinCircle
# coordinates given by a suitable data frame bb <- getMinBBox(DFsavage) # minimum bounding box # plot points and minimum bounding box plot(point.y ~ point.x, data=DFsavage, asp=1, xlim=range(bb$pts[ , 1]), ylim=range(bb$pts[ , 2]), pch=16) drawBox2(bb, fg='blue', colCtr='blue', pch=4, cex=2) bb$FoM # figure of merit bb$angle # box orientation # coordinates given by a matrix ## Not run: xy <- matrix(round(rnorm(16, 100, 15)), ncol=2) getMinBBox(xy) ## End(Not run)
# coordinates given by a suitable data frame bb <- getMinBBox(DFsavage) # minimum bounding box # plot points and minimum bounding box plot(point.y ~ point.x, data=DFsavage, asp=1, xlim=range(bb$pts[ , 1]), ylim=range(bb$pts[ , 2]), pch=16) drawBox2(bb, fg='blue', colCtr='blue', pch=4, cex=2) bb$FoM # figure of merit bb$angle # box orientation # coordinates given by a matrix ## Not run: xy <- matrix(round(rnorm(16, 100, 15)), ncol=2) getMinBBox(xy) ## End(Not run)
Calculates center and radius of the minimum enclosing circle given a set of 2D-coordinates.
getMinCircle(xy) ## S3 method for class 'data.frame' getMinCircle(xy) ## Default S3 method: getMinCircle(xy)
getMinCircle(xy) ## S3 method for class 'data.frame' getMinCircle(xy) ## Default S3 method: getMinCircle(xy)
xy |
either a numerical (n x 2)-matrix with the (x,y)-coordinates of n >= 2 points (1 row of coordinates per point), or a data frame with either the variables |
No coordinate transforms are done (unlike in groupLocation
, groupShape
, groupSpread
), i.e., origin is not assumed to be in top-left corner, and points are not taken relative to point of aim.
Uses the Skyum algorithm based on the convex hull.
A list containing the center and radius of the circle.
ctr |
a numerical 2-vector giving the (x,y)-coordinates of the circle's center. |
rad |
a numerical value giving the radius of the circle. |
Computational Geometry Algorithms Library. 2021. CGAL Chapter 65: Bounding Volumes. https://doc.cgal.org/Manual/latest/doc_html/cgal_manual/Bounding_volumes/Chapter_main.html Fischer, K.; Gaertner, B.; Kutz, M. 2003. Fast smallest-enclosing-ball computation in high dimensions. In: Proceedings of the 11th European Symposium on Algorithms (ESA), 630-641. https://github.com/hbf/miniball Gaertner, B. 2021. Miniball: Smallest Enclosing Balls of Points. https://people.inf.ethz.ch/gaertner/subdir/software/miniball.html Skyum, S. 1991. A simple algorithm for computing the smallest enclosing circle. Information Processing Letters 37(3), 121-125. Welzl, E. 1991. Smallest enclosing disks (balls and ellipsoids). In: Maurer H. (eds), New Results and New Trends in Computer Science 555, 359-370. doi 10.1007/BFb0038202.
drawCircle
,
getMinBBox
,
getBoundingBox
# coordinates given by a suitable data frame mc <- getMinCircle(DFsavage) # determine axis limits so that circle will be visible xLims <- mc$ctr[1] + c(-mc$rad, mc$rad) yLims <- mc$ctr[2] + c(-mc$rad, mc$rad) plot(point.y ~ point.x, data=DFsavage, pch=16, asp=1, xlim=xLims, ylim=yLims) drawCircle(mc, fg='blue') # coordinates given by a matrix ## Not run: xy <- matrix(round(rnorm(20, 100, 15), 2), ncol=2) getMinCircle(xy) ## End(Not run)
# coordinates given by a suitable data frame mc <- getMinCircle(DFsavage) # determine axis limits so that circle will be visible xLims <- mc$ctr[1] + c(-mc$rad, mc$rad) yLims <- mc$ctr[2] + c(-mc$rad, mc$rad) plot(point.y ~ point.x, data=DFsavage, pch=16, asp=1, xlim=xLims, ylim=yLims) drawCircle(mc, fg='blue') # coordinates given by a matrix ## Not run: xy <- matrix(round(rnorm(20, 100, 15), 2), ncol=2) getMinCircle(xy) ## End(Not run)
Calculates center, shape matrix, and area of the minimum enclosing ellipse given a set of 2D-coordinates using Khachiyan's algorithm.
getMinEllipse(xy, tol = 0.001, max_iter = 1000) ## S3 method for class 'data.frame' getMinEllipse(xy, tol = 0.001, max_iter = 1000) ## Default S3 method: getMinEllipse(xy, tol = 0.001, max_iter = 1000)
getMinEllipse(xy, tol = 0.001, max_iter = 1000) ## S3 method for class 'data.frame' getMinEllipse(xy, tol = 0.001, max_iter = 1000) ## Default S3 method: getMinEllipse(xy, tol = 0.001, max_iter = 1000)
xy |
either a numerical (n x 2)-matrix with the (x,y)-coordinates of n >= 2 points (1 row of coordinates per point), or a data frame with either the variables |
tol |
numerical tolerance value. Should be < 1. |
max_iter |
maximum number of iterations. |
No coordinate transforms are done (unlike in groupLocation
, groupShape
, groupSpread
), i.e., origin is not assumed to be in top-left corner, and points are not taken relative to point of aim.
A list containing the center, (2 x 2)-shape matrix, and area of the ellipse.
ctr |
a numerical 2-vector giving the (x,y)-coordinates of the ellipse's center. |
E |
a numerical positive definite (2 x 2)-matrix defining the ellipse in the form ((x-c)' E (x-c)) <= 1 |
cov |
matrix, whose eigen-structure determines shape of ellipse. Inverse of E. Useful for plotting with |
area |
a numerical value giving the area of the ellipse. |
shape |
a numerical vector with the orientation of the ellipse's major axis pointing up as returned by |
size |
a numerical vector with the lengths of the semi-axes of the ellipse. |
Computational Geometry Algorithms Library. 2021. CGAL Chapter 65: Bounding Volumes. https://doc.cgal.org/Manual/latest/doc_html/cgal_manual/Bounding_volumes/Chapter_main.html
Todd MJ and Yildrim EA. On Khachiyan's Algorithm for the Computation of Minimum Volume Enclosing Ellipsoids. Discrete Applied Mathematics 2007: 155: 1731-1744. https://people.orie.cornell.edu/miketodd/TYKhach.pdf
Jacob. Bounding ellipse. https://stackoverflow.com/a/1768440.
drawEllipse
,
getMinCircle
,
getMinBBox
,
getBoundingBox
# coordinates given by a suitable data frame me <- getMinEllipse(DFsavage, tol=0.001) plot(point.y ~ point.x, data=DFsavage, pch=16, asp=1) drawEllipse(me, fg='blue') # coordinates given by a matrix ## Not run: xy <- matrix(round(rnorm(20, 100, 15), 2), ncol=2) getMinEllipse(xy, tol=0.001) ## End(Not run)
# coordinates given by a suitable data frame me <- getMinEllipse(DFsavage, tol=0.001) plot(point.y ~ point.x, data=DFsavage, pch=16, asp=1) drawEllipse(me, fg='blue') # coordinates given by a matrix ## Not run: xy <- matrix(round(rnorm(20, 100, 15), 2), ncol=2) getMinEllipse(xy, tol=0.001) ## End(Not run)
Converts object size to angular diameter (degree, radian, minute of angle MOA = arcminute, Shooter's MOA SMOA, milliradian mrad, NATO mil).
getMOA(x, dst, conversion, type = c('deg', 'rad', 'MOA', 'SMOA', 'mrad', 'mil'))
getMOA(x, dst, conversion, type = c('deg', 'rad', 'MOA', 'SMOA', 'mrad', 'mil'))
x |
a numerical vector of object sizes. |
dst |
a numerical vector of viewing distances. |
conversion |
how to convert the measurement unit for distance to target to that of the (x,y)-coordinates. Either a character vector indicating the conversion such as |
type |
type of angular diameter: |
1 MOA (minute of angle, arcmin) = 1/60 degree. Shooter's MOA = SMOA = Inches Per Hundred Yards IPHY. 1 inch at 100 yards = 1 SMOA. 1 milliradian = 1/1000 radian. 1 mil = 2*pi/6400 radian (NATO definition: the circle circumference is divided into 6400 mils). Details are given in the vignette, see vignette('shotGroups') .
If package shiny
is installed, an interactive web app for this functionality can be run with runGUI("angular")
.
A numerical vector with the angular diameter values.
size <- seq(1, 20, by=5) # inch dst <- 100 # yard getMOA(size, dst=dst, conversion='yd2in', type='MOA') # this should return objSize MOA <- getMOA(size, dst=dst, conversion='yd2in', type='MOA') fromMOA(MOA, dst=dst, conversion='yd2in', type='MOA') # SMOA getMOA(c(1, 2, 5), dst=100, conversion='yd2in', type='SMOA') # milliradian getMOA(c(10, 20, 50), dst=100, conversion='m2mm', type='mrad')
size <- seq(1, 20, by=5) # inch dst <- 100 # yard getMOA(size, dst=dst, conversion='yd2in', type='MOA') # this should return objSize MOA <- getMOA(size, dst=dst, conversion='yd2in', type='MOA') fromMOA(MOA, dst=dst, conversion='yd2in', type='MOA') # SMOA getMOA(c(1, 2, 5), dst=100, conversion='yd2in', type='SMOA') # milliradian getMOA(c(10, 20, 50), dst=100, conversion='m2mm', type='mrad')
Returns range statistics: extreme spread, figure of merit, bounding box diagonal
getRangeStat(xy, dstTarget, conversion) ## S3 method for class 'data.frame' getRangeStat(xy, dstTarget, conversion) ## Default S3 method: getRangeStat(xy, dstTarget, conversion)
getRangeStat(xy, dstTarget, conversion) ## S3 method for class 'data.frame' getRangeStat(xy, dstTarget, conversion) ## Default S3 method: getRangeStat(xy, dstTarget, conversion)
xy |
either a numerical (n x p)-matrix with the coordinates of n points (1 row of p coordinates per point), or a data frame with either the variables |
dstTarget |
a numerical value giving the distance to the target - used in MOA calculation. Acts as override if variable |
conversion |
how to convert the measurement unit for distance to target to that of the (x,y)-coordinates in MOA calculation. Acts as override if variables |
A named numeric vector with elements ES
(extreme spread), FoM
(figure of merit), D
(bounding box diagonal).
Grubbs, F. E. (1964b). Statistical measures of accuracy for riflemen and missile engineers. Ann Arbor, ML: Edwards Brothers.
getMaxPairDist
,
getBoundingBox
getRangeStat(DFscar17)
getRangeStat(DFscar17)
Estimates the radial precision parameter sigma of the Rayleigh distribution together with the radial mean MR and radial standard deviation RSD, including parametric confidence intervals. For 1D data, it estimates the parameters of the half normal distribution. For 3D data, it estimates the parameters of the Maxwell-Boltzmann distribution
getRayParam(xy, level = 0.95, mu, doRob = FALSE) ## S3 method for class 'data.frame' getRayParam(xy, level = 0.95, mu, doRob = FALSE) ## Default S3 method: getRayParam(xy, level = 0.95, mu, doRob = FALSE)
getRayParam(xy, level = 0.95, mu, doRob = FALSE) ## S3 method for class 'data.frame' getRayParam(xy, level = 0.95, mu, doRob = FALSE) ## Default S3 method: getRayParam(xy, level = 0.95, mu, doRob = FALSE)
xy |
either a numerical matrix with the coordinates of n points (1 row of coordinates per point), or a data frame with either the variables |
level |
a numerical value with the coverage for the confidence intervals for sigma, MR, RSD. |
mu |
numerical 2-vector with the true group center (optional). See details. |
doRob |
logical: use robust estimation of covariance matrix as basis for estimators? |
When the true mean mu
of the distribution is given, the sigma estimate uses the sum of squared radii for the variance estimate (the total un-corrected variance of the coordinates), and employs the c4 correction factor for taking the square root. When mu
is missing, the sum of squared radii is Bessel-corrected for estimating the center.
The robust estimate for the covariance matrix of (x,y)-coordinates is from covMcd
using the MCD algorithm.
A list with the estimates for sigma, RSD, and MR including the confidence intervals.
sigma |
A vector with the sigma estimate and confidence interval bounds as named elements |
RSD |
A vector with the RSD estimate and confidence interval bounds as named elements |
MR |
A vector with the MR estimate and confidence interval bounds as named elements |
http://ballistipedia.com/index.php?title=Closed_Form_Precision
Singh, H. P. 1992. Estimation of Circular Probable Error. The Indian Journal of Statistics, Series B 5(3), 289-305.
Rayleigh
,
Maxwell
,
getCEP
,
getHitProb
,
groupSpread
,
covMcd
# coordinates given by a suitable data frame getRayParam(DFtalon, level=0.95, doRob=FALSE) # coordinates given by a matrix ## Not run: xy <- matrix(round(rnorm(100, 0, 5), 2), ncol=2) getRayParam(xy, level=0.95, doRob=FALSE) ## End(Not run)
# coordinates given by a suitable data frame getRayParam(DFtalon, level=0.95, doRob=FALSE) # coordinates given by a matrix ## Not run: xy <- matrix(round(rnorm(100, 0, 5), 2), ncol=2) getRayParam(xy, level=0.95, doRob=FALSE) ## End(Not run)
Estimates the location parameter nu and the scale parameter sigma of the Rice distribution together with the radial mean MR and radial standard deviation RSD based on a set of 2D-coordinates. Includes the parametric confidence interval for sigma.
getRiceParam(xy, level = 0.95, doRob = FALSE, type = c('LiZhangDai', 'MOM')) ## S3 method for class 'data.frame' getRiceParam(xy, level = 0.95, doRob = FALSE, type=c('LiZhangDai', 'MOM')) ## Default S3 method: getRiceParam(xy, level = 0.95, doRob = FALSE, type=c("LiZhangDai", 'MOM'))
getRiceParam(xy, level = 0.95, doRob = FALSE, type = c('LiZhangDai', 'MOM')) ## S3 method for class 'data.frame' getRiceParam(xy, level = 0.95, doRob = FALSE, type=c('LiZhangDai', 'MOM')) ## Default S3 method: getRiceParam(xy, level = 0.95, doRob = FALSE, type=c("LiZhangDai", 'MOM'))
xy |
either a numerical (n x 2)-matrix with the (x,y)-coordinates of n points (1 row of coordinates per point), or a data frame with either the variables |
level |
a numerical value with the coverage for the confidence interval for sigma. |
doRob |
logical: use robust estimation of center and covariance matrix as basis for estimators? |
type |
The initial biased nu estimate is the Euclidean norm of the group center. For |
The sigma estimate uses getRayParam
. The robust estimate for the center and for the covariance matrix of (x,y,z)-coordinates is from covMcd
using the MCD algorithm.
A list with the estimates for nu, sigma, RSD, and MR including the confidence interval for sigma.
nu |
The estimated location parameter nu. |
sigma |
A vector with the sigma estimate and confidence interval bounds as named elements |
MR |
The MR estimate. |
RSD |
The RSD estimate. |
https://reference.wolfram.com/language/ref/RiceDistribution.html
Li, Q., Zhang, J., & Dai, S. (2009). On estimating the non-centrality parameter of a chi-squared distribution. Statistics and Probability Letters 79, 98-114.
Rice
,
getRayParam
,
getCEP
,
getHitProb
,
covMcd
getRiceParam(DF300BLKhl, level=0.95, doRob=FALSE) # coordinates given by a matrix ## Not run: xy <- matrix(round(rnorm(60, 0, 5), 2), ncol=2) getRiceParam(xy, level=0.95, doRob=FALSE) ## End(Not run)
getRiceParam(DF300BLKhl, level=0.95, doRob=FALSE) # coordinates given by a matrix ## Not run: xy <- matrix(round(rnorm(60, 0, 5), 2), ncol=2) getRiceParam(xy, level=0.95, doRob=FALSE) ## End(Not run)
Extracts (x,y)- or (x,y,z)-coordinates of the points of impact (relative to the point of aim) from a data frame and returns them as a matrix.
getXYmat(DF, xyTopLeft = TRUE, relPOA = TRUE, center = FALSE)
getXYmat(DF, xyTopLeft = TRUE, relPOA = TRUE, center = FALSE)
DF |
a data frame containing (at least) either the variables |
xyTopLeft |
logical: is the origin of the absolute coordinate system in the top-left corner? See details. |
relPOA |
logical: should returned coordinates be relative to the point of aim? |
center |
logical: center groups to mean (0,0)? If variable |
By default, OnTarget PC/TDS' 'Export Point Data' places the origin of the absolute coordinate system in the top-left corner. In OnTarget TDS, this setting can be changed by checking the box 'Tools -> Options -> Options tab -> Data Export -> Invert Y-Axis on Export'. In that case, use xyTopLeft=FALSE
. If groups appear to be upside-down, xyTopLeft
is the setting to change.
A numerical matrix with the (x,y)- or (x,y,z)-coordinates.
groupLocation
,
groupShape
,
groupSpread
data(DFcm) # select data from only first series DFsub <- subset(DFcm, series == 1) getXYmat(DFsub, xyTopLeft=TRUE, relPOA=TRUE)
data(DFcm) # select data from only first series DFsub <- subset(DFcm, series == 1) getXYmat(DFsub, xyTopLeft=TRUE, relPOA=TRUE)
Calculates location measures for a single group of bullet holes.
groupLocation(xy, level = 0.95, plots = TRUE, bootCI = 'none', dstTarget, conversion) ## S3 method for class 'data.frame' groupLocation(xy, level = 0.95, plots = TRUE, bootCI = 'none', dstTarget, conversion) ## Default S3 method: groupLocation(xy, level = 0.95, plots = TRUE, bootCI = 'none', dstTarget, conversion)
groupLocation(xy, level = 0.95, plots = TRUE, bootCI = 'none', dstTarget, conversion) ## S3 method for class 'data.frame' groupLocation(xy, level = 0.95, plots = TRUE, bootCI = 'none', dstTarget, conversion) ## Default S3 method: groupLocation(xy, level = 0.95, plots = TRUE, bootCI = 'none', dstTarget, conversion)
xy |
either a numerical (n x 2)-matrix with the (x,y)-coordinates of n points (1 row of coordinates per point), or a data frame with either the variables |
level |
a numerical value giving the level for the confidence intervals for the center (x,y)-coordinates. |
plots |
logical: show a 2D-scatterplot? |
bootCI |
a character vector to select which bootstrap confidence interval type to report. Possible types are |
dstTarget |
a numerical value giving the distance to the target - used in MOA calculation. Acts as override if variable |
conversion |
how to convert the measurement unit for distance to target to that of the (x,y)-coordinates in MOA calculation. Acts as override if variables |
The number of replicates for the reported bootstrap confidence intervals is at least 1499. If the BCa interval is reported, it is at least the number of points.
If package shiny
is installed, an interactive web app for this functionality can be run with runGUI("analyze")
.
A list with the results from the numerical analyses and statistical tests.
ctr |
(x,y)-offset of group center relative to point of aim. |
ctrXci |
parametric (t) and bootstrap confidence intervals for center x-coordinate. |
ctrYci |
parametric (t) and bootstrap confidence intervals for center y-coordinate. |
ctrRob |
robust estimate of group center offset relative to point of aim (MCD algorithm). |
distPOA |
distance from group center to point of aim (in original measurement units, MOA, SMOA, milliradian). |
distPOArob |
distance from robust estimate of group center to point of aim (in original measurement units, MOA, SMOA, milliradian). |
Hotelling |
Hotelling's T^2-Test result from testing if group center equals point of aim. |
getMOA
,
covMcd
,
anova.mlm
,
boot
,
boot.ci
# coordinates given by a suitable data frame res <- groupLocation(DFsavage, dstTarget=100, conversion='m2mm', level=0.95, plots=2, bootCI='basic') names(res) res$ctr res$distPOA res$ctrXci res$ctrYci # coordinates given by a matrix ## Not run: # assume data from pistol shooting at 25m with 9mm ammo # metric units xy <- matrix(round(rnorm(100, 0, 5), 2), ncol=2) groupLocation(xy, dstTarget=25, conversion='m2cm', plots=2) ## End(Not run)
# coordinates given by a suitable data frame res <- groupLocation(DFsavage, dstTarget=100, conversion='m2mm', level=0.95, plots=2, bootCI='basic') names(res) res$ctr res$distPOA res$ctrXci res$ctrYci # coordinates given by a matrix ## Not run: # assume data from pistol shooting at 25m with 9mm ammo # metric units xy <- matrix(round(rnorm(100, 0, 5), 2), ncol=2) groupLocation(xy, dstTarget=25, conversion='m2cm', plots=2) ## End(Not run)
Assesses shape of a single group of bullet holes: Outlier analysis as well as numerical and graphical normality checks for a set of (x,y)-coordinates.
groupShape(xy, center = FALSE, plots = TRUE, bandW = 0.5, outlier = c('mcd', 'pca'), dstTarget, conversion, ...) ## S3 method for class 'data.frame' groupShape(xy, center = FALSE, plots = TRUE, bandW = 0.5, outlier=c('mcd', 'pca'), dstTarget, conversion, ...) ## Default S3 method: groupShape(xy, center = FALSE, plots = TRUE, bandW = 0.5, outlier=c('mcd', 'pca'), dstTarget, conversion, ...)
groupShape(xy, center = FALSE, plots = TRUE, bandW = 0.5, outlier = c('mcd', 'pca'), dstTarget, conversion, ...) ## S3 method for class 'data.frame' groupShape(xy, center = FALSE, plots = TRUE, bandW = 0.5, outlier=c('mcd', 'pca'), dstTarget, conversion, ...) ## Default S3 method: groupShape(xy, center = FALSE, plots = TRUE, bandW = 0.5, outlier=c('mcd', 'pca'), dstTarget, conversion, ...)
xy |
either a numerical (n x 2)-matrix with the (x,y)-coordinates of n points (1 row of coordinates per point), or a data frame with either the variables |
center |
logical: center groups to mean (0,0) first? If variable |
plots |
logical: show diagrams? |
bandW |
for argument |
outlier |
method for outlier identification: |
dstTarget |
a numerical value giving the distance to the target - used in MOA calculation. Acts as override if variable |
conversion |
how to convert the measurement unit for distance to target to that of the (x,y)-coordinates in MOA calculation. Acts as override if variables |
... |
additional arguments passed to |
In addition to the numerical results listed below, this function produces the following diagrams:
a combined plot for multivariate outlier identification as produced by aq.plot
- requires installing package mvoutlier
a chi-square Q-Q-plot for eyeballing multivariate normality as produced by chisq.plot
, including a reference line with intercept 0 and slope 1
a heatmap of a non-parametric 2D-kernel density estimate for the (x,y)-coordinates as produced by smoothScatter
together with group center and error ellipses (original and scaled by factor 2) based on a robust estimate for the covariance matrix (from covMcd
using the MCD algorithm)
a Q-Q-plot of x-coordinates for eyeballing normality
a Q-Q-plot of y-coordinates for eyeballing normality
a histogram of x-coordinates including a fitted normal distribution as well as a non-parametric kernel density estimate
a histogram of y-coordinates including a fitted normal distribution as well as a non-parametric kernel density estimate
If package shiny
is installed, an interactive web app for this functionality can be run with runGUI("analyze")
.
A list with the results from the numerical analyses and statistical tests.
corXY |
correlation matrix of (x,y)-coordinates. |
corXYrob |
robust estimate of correlation matrix of (x,y)-coordinates. |
Outliers |
a vector of row indices for observations identified as outliers - only if package |
ShapiroX |
Shapiro-Wilk-Test result for normality of x-coordinates. Only for at most 5000 points. For more than 5000 points, replaced by Kolmogorov-Smirnov-Test in |
ShapiroY |
Shapiro-Wilk-Test result for normality of y-coordinates. Only for at most 5000 points. For more than 5000 points, replaced by Kolmogorov-Smirnov-Test in |
multNorm |
E-statistic-Test result for multivariate normality of (x,y)-coordinates - only available if package |
The chi-square distribution is only strictly valid for squared Mahalanobis distances if the true center and the true covariance matrix are used in calculation. The goodness of approximation for situations where sample estimates are used should be sufficient here.
qqnorm
,
smoothScatter
,
hist
,
kernel
,
covMcd
,
shapiro.test
,
ks.test
,
mvnorm.etest
,
chisq.plot
,
aq.plot
,
pcout
# coordinates given by a suitable data frame res <- groupShape(DFsavage, bandW=4, outlier='mcd', dstTarget=100, conversion='m2mm') names(res) res$corXY res$Outliers res$multNorm # coordinates given by a matrix ## Not run: xy <- matrix(round(rnorm(200, 0, 5), 2), ncol=2) groupShape(xy, bandW=1.6) ## End(Not run)
# coordinates given by a suitable data frame res <- groupShape(DFsavage, bandW=4, outlier='mcd', dstTarget=100, conversion='m2mm') names(res) res$corXY res$Outliers res$multNorm # coordinates given by a matrix ## Not run: xy <- matrix(round(rnorm(200, 0, 5), 2), ncol=2) groupShape(xy, bandW=1.6) ## End(Not run)
Provides spread measures and their graphical representations for a single group of bullet holes.
groupSpread(xy, center = FALSE, plots = TRUE, CEPlevel = 0.5, CIlevel = 0.95, CEPtype = 'CorrNormal', bootCI = 'none', dstTarget, conversion) ## S3 method for class 'data.frame' groupSpread(xy, center = FALSE, plots = TRUE, CEPlevel = 0.5, CIlevel = 0.95, CEPtype = 'CorrNormal', bootCI = 'none', dstTarget, conversion) ## Default S3 method: groupSpread(xy, center = FALSE, plots = TRUE, CEPlevel = 0.5, CIlevel = 0.95, CEPtype = 'CorrNormal', bootCI = 'none', dstTarget, conversion)
groupSpread(xy, center = FALSE, plots = TRUE, CEPlevel = 0.5, CIlevel = 0.95, CEPtype = 'CorrNormal', bootCI = 'none', dstTarget, conversion) ## S3 method for class 'data.frame' groupSpread(xy, center = FALSE, plots = TRUE, CEPlevel = 0.5, CIlevel = 0.95, CEPtype = 'CorrNormal', bootCI = 'none', dstTarget, conversion) ## Default S3 method: groupSpread(xy, center = FALSE, plots = TRUE, CEPlevel = 0.5, CIlevel = 0.95, CEPtype = 'CorrNormal', bootCI = 'none', dstTarget, conversion)
xy |
either a numerical (n x 2)-matrix with the (x,y)-coordinates of n points (1 row of coordinates per point), or a data frame with either the variables |
center |
logical: center groups to mean (0,0) first? If variable |
plots |
logical: show diagrams? |
CEPlevel |
a numerical value giving the coverage for the CEP and for the confidence ellipse. |
CIlevel |
a numerical value giving the level for the confidence intervals (for standard deviations as well as for Rayleigh sigma, RSD, MR). |
CEPtype |
string indicating which CEP estimate to report from |
bootCI |
a character vector to select which bootstrap confidence interval type to report. Possible types are |
dstTarget |
a numerical value giving the distance to the target - used in MOA calculation. Acts as override if variable |
conversion |
how to convert the measurement unit for distance to target to that of the (x,y)-coordinates in MOA calculation. Acts as override if variables |
Explanations and formula for many reported precision measures such as CEP, sigma, RSD, MR, FoM can be found in the references.
Robust estimate for the covariance matrix of (x,y)-coordinates is from covMcd
using the MCD algorithm.
The number of replicates for the reported bootstrap confidence intervals is at least 1499. If the BCa interval is reported, it is at least the number of points.
In addition to the numerical results listed below, this function produces the following diagrams:
a scatterplot of the (x,y)-coordinates together with group center, circle with average distance to center, and 100*level
%-confidence ellipse - the latter also based on a robust estimate for the covariance matrix
a scatterplot of the (x,y)-coordinates together with the bounding box, minimum bounding box, minimum enclosing circle, and maximum group spread
a histogram of distances to group center including a fitted Rayleigh distribution as well as a non-parametric kernel density estimate
If package shiny
is installed, an interactive web app for this functionality can be run with runGUI("analyze")
.
A list with the results from the numerical analyses and statistical tests.
sdXY |
standard deviations of x- and y-coordinates (in original measurement units, MOA, SMOA, milliradian). |
sdXci |
parametric (chi^2) and bootstrap confidence intervals for the standard deviation of x-coordinates (in original measurement units, MOA, SMOA, milliradian). |
sdYci |
parametric (chi^2) and bootstrap confidence intervals for the standard deviation of y-coordinates (in original measurement units, MOA, SMOA, milliradian). |
sdXYrob |
robust standard deviations of x- and y-coordinates (in original measurement units, MOA, SMOA, milliradian). |
covXY |
covariance matrix of (x,y)-coordinates. |
covXYrob |
robust estimate of covariance matrix of (x,y)-coordinates. |
distToCtr |
mean, median and maximum distance from points to their center as well as estimated Rayleigh parameters sigma (precision), radial standard deviation RSD, and mean radius MR (in original measurement units, MOA, SMOA, milliradian). |
sigmaCI |
parametric (chi^2) and bootstrap confidence intervals for sigma (in original measurement units, MOA, SMOA, milliradian). |
RSDci |
parametric (chi^2) and bootstrap confidence intervals for radial standard deviation RSD (number of points), in original measurement units, MOA, SMOA, milliradian). |
MRci |
parametric (chi^2) and bootstrap confidence intervals for mean radius MR (in original measurement units, MOA, SMOA, milliradian). |
maxPairDist |
maximum pairwise distance between points (center-to-center, = maximum spread, in original measurement units, MOA, SMOA, milliradian). |
groupRect |
width and height of bounding box with diagonal and figure of merit FoM (average side length, in original measurement units, MOA, SMOA, milliradian). |
groupRectMin |
width and height of minimum-area bounding box with diagonal and figure of merit FoM (average side length, in original measurement units, MOA, SMOA, milliradian). |
minCircleRad |
radius for the minimum enclosing circle (in original measurement units, MOA, SMOA, milliradian). |
minEll |
length of semi-major and semi-minor axis of the minimum enclosing ellipse (in original measurement units, MOA, SMOA, milliradian). |
confEll |
length of semi-major and semi-minor axis of the confidence ellipse (in original measurement units, MOA, SMOA, milliradian). |
confEllRob |
length of semi-major and semi-minor axis of the confidence ellipse based on a robust estimate for the covariance matrix (in original measurement units, MOA, SMOA, milliradian). |
confEllShape |
aspect ratio of the confidence ellipse (square root of condition index |
confEllShapeRob |
aspect ratio and flattening of the confidence ellipse based on a robust estimate for the covariance matrix as well as its trace and determinant. |
CEP |
estimate(s) for the circular error probable (CEP, in original measurement units, MOA, SMOA, milliradian). |
http://ballistipedia.com/index.php?title=Describing_Precision
http://ballistipedia.com/index.php?title=Measuring_Precision
getDistToCtr
,
getMaxPairDist
,
getBoundingBox
,
getMinBBox
,
getMinCircle
,
getConfEll
,
getCEP
,
getRayParam
,
getMOA
,
hist
,
boot
,
boot.ci
,
kernel
,
covMcd
# coordinates given by a suitable data frame res <- groupSpread(DFtalon, CEPtype=c('Grubbs', 'Rayleigh'), CEPlevel=0.5, CIlevel=0.95, bootCI='none', dstTarget=10, conversion='m2mm') names(res) res$sdXYrob res$distToCtr res$maxPairDist res$CEP # coordinates given by a matrix ## Not run: xy <- matrix(round(rnorm(200, 0, 5), 2), ncol=2) groupSpread(xy, CEPlevel=0.5, CIlevel=0.95, dstTarget=25, conversion='m2cm') ## End(Not run)
# coordinates given by a suitable data frame res <- groupSpread(DFtalon, CEPtype=c('Grubbs', 'Rayleigh'), CEPlevel=0.5, CIlevel=0.95, bootCI='none', dstTarget=10, conversion='m2mm') names(res) res$sdXYrob res$distToCtr res$maxPairDist res$CEP # coordinates given by a matrix ## Not run: xy <- matrix(round(rnorm(200, 0, 5), 2), ncol=2) groupSpread(xy, CEPlevel=0.5, CIlevel=0.95, dstTarget=25, conversion='m2cm') ## End(Not run)
Density, distribution function, quantile function, and random deviate generation for the Hoyt distribution. The radius around the true mean in a bivariate normal random variable, re-written in polar coordinates (radius and angle), follows a Hoyt distribution. Equivalently, the modulus of a complex normal random variable does.
dHoyt(x, qpar, omega) pHoyt(q, qpar, omega, lower.tail = TRUE) qHoyt(p, qpar, omega, lower.tail = TRUE, loUp = NULL) rHoyt(n, qpar, omega, method = c('eigen', 'chol', 'cdf'), loUp = NULL)
dHoyt(x, qpar, omega) pHoyt(q, qpar, omega, lower.tail = TRUE) qHoyt(p, qpar, omega, lower.tail = TRUE, loUp = NULL) rHoyt(n, qpar, omega, method = c('eigen', 'chol', 'cdf'), loUp = NULL)
x , q
|
vector of quantiles. |
p |
vector of probabilities. |
n |
number of observations. If |
qpar |
vector of Hoyt shape parameters q. See details. |
omega |
vector of Hoyt scale parameters omega. See details. |
method |
string indicating which method to use for generating random deviates. See details. |
loUp |
search interval for numerical root finding. Either a vector with the lower and upper interval boundary, a list of such vectors, or an (n x 2)-matrix. See details. |
lower.tail |
logical. If |
The parameters qpar
and omega
may be determined with getHoytParam
.
dHoyt
involves the modified Bessel function of the first kind and order 0 (Chew & Boye, 1962; Hoyt, 1947). pHoyt
is implemented as the symmetric difference between two Marcum Q-functions (Paris, 2009). The Marcum Q-function is the cdf of a non-central chi^2 variable (Nuttall, 1975).
qHoyt
is implemented through numerical root finding of pHoyt
. If no search interval for uniroot
is provided, the quantiles of an approximating central chi^2 distribution are used to determine the search intervals.
rHoyt
with method='eigen'
or with method='chol'
simulates 2D normal deviates based on the covariance matrix corresponding to parameters qpar
and omega
, and then determines the radius. rHoyt
with method='cdf'
is much slower as it performs numerical root finding of pHoyt
given simulated quantiles from a uniform random variable in (0,1). If no search interval for uniroot
is provided, the quantiles of an approximating central chi^2 distribution are used to determine the search intervals.
See Rice
for the distribution of radial error around an offset center for uncorrelated bivariate normal variables with equal variances. See Rayleigh
for the distribution of radial error around the true center of uncorrelated bivariate normal variables with equal variances. See mvnEll
for the distribution of radial error around an offset center for correlated normal variables with unequal variances.
dHoyt
gives the density, pHoyt
gives the cumulative distribution function, qHoyt
gives the quantile function, rHoyt
generates random deviates.
The length of the result is determined by n
for rHoyt
, and is the maximum of the lengths of the numerical parameters for the other functions.
In dHoyt
, pHoyt
and qHoyt
, the numerical parameters are recycled to the length of the result. Only the first element of the logical parameters is used. In rHoyt
, only the first element of qpar
and omega
is used.
Chew, V. & Boyce, R. (1962). Distribution of radial error in bivariate elliptical normal distributions. Technometrics, 4(1), 138-140.
Hoyt, R. S. (1947). Probability functions for the modulus and angle of the normal complex variate. Bell System Technical Journal, 26(2), 318-359.
Nuttall, AH. (1975). Some integrals involving the Q-M function. IEEE Transactions on Information Theory, 21 (1), 95-96
Paris, JF. 2009. Nakagami-q (Hoyt) distribution function with applications. Electronics Letters, 45(4). 210-211. Erratum: doi:10.1049/el.2009.0828
https://reference.wolfram.com/language/ref/HoytDistribution.html
getHoytParam
,
Rayleigh
,
Rice
,
mvnEll
,
Bessel
,
Chisquare
,
uniroot
dHoyt(1, qpar=c(0.1, 0.5, 0.9), omega=10) pHoyt(c(0.1, 0.5, 0.9), qpar=0.5, omega=10) qHoyt(0.5, qpar=0.5, omega=c(5, 10, 15)) rHoyt(5, qpar=0.5, omega=10)
dHoyt(1, qpar=c(0.1, 0.5, 0.9), omega=10) pHoyt(c(0.1, 0.5, 0.9), qpar=0.5, omega=10) qHoyt(0.5, qpar=0.5, omega=c(5, 10, 15)) rHoyt(5, qpar=0.5, omega=10)
Density, distribution function, quantile function, and random deviate generation for the Maxwell-Boltzmann distribution. The radius around the true mean in a trivariate uncorrelated normal random variable with equal variances, re-written in polar coordinates (radius, azimuth, elevation), follows a Maxwell-Boltzmann distribution.
dMaxwell(x, sigma) pMaxwell(q, sigma, lower.tail = TRUE) qMaxwell(p, sigma, lower.tail = TRUE) rMaxwell(n, sigma)
dMaxwell(x, sigma) pMaxwell(q, sigma, lower.tail = TRUE) qMaxwell(p, sigma, lower.tail = TRUE) rMaxwell(n, sigma)
x , q
|
vector of quantiles. |
p |
vector of probabilities. |
n |
number of observations. If |
sigma |
vector of parameter sigma (common standard deviation of the underlying normal distribution of each 3D-coordinate). |
lower.tail |
logical. If |
The parameter sigma
may be determined with getRayParam
.
See Rayleigh
for the distribution of radial error around the true center of uncorrelated bivariate normal variables with equal variances. See Hoyt
for the distribution of radial error around the true center of correlated bivariate normal variables with unequal variances. See Rice
for the distribution of radial error around an offset center for uncorrelated bivariate normal variables with equal variances. See mvnEll
for the distribution of radial error around an offset center for correlated normal variables with unequal variances.
dMaxwell
gives the density, pMaxwell
gives the cumulative distribution function, qMaxwell
gives the quantile function, rMaxwell
generates random deviates.
The length of the result is determined by n
for rMaxwell
, and is the maximum of the lengths of the numerical parameters for the other functions.
In dMaxwell
, pMaxwell
and qMaxwell
are recycled to the length of the result. Only the first element of the logical parameters is used. In rRayleigh
, only the first element of sigma
is used.
https://reference.wolfram.com/language/ref/MaxwellDistribution.html
getRayParam
,
Rayleigh
,
Hoyt
,
Rice
,
mvnEll
dMaxwell(1, sigma=10) pMaxwell(c(0.1, 0.5, 0.9), sigma=10) qMaxwell(0.5, sigma=c(5, 10, 15)) rMaxwell(5, sigma=10)
dMaxwell(1, sigma=10) pMaxwell(c(0.1, 0.5, 0.9), sigma=10) qMaxwell(0.5, sigma=c(5, 10, 15)) rMaxwell(5, sigma=10)
Probability of an offset ellipsoid for a correlated multivariate normal distribution. Offset circle probabilities are a special case.
pmvnEll(r=1, sigma = diag(2), mu, e, x0, lower.tail = TRUE, method_cdf = c('integrate', 'saddlepoint')) qmvnEll(p, sigma = diag(2), mu, e, x0, lower.tail = TRUE, loUp=NULL, method_cdf = c('integrate', 'saddlepoint')) rmvnEll(n, sigma = diag(2), mu, e, x0, method = c('eigen', 'chol', 'cdf'), loUp=NULL, method_cdf = c('integrate', 'saddlepoint'))
pmvnEll(r=1, sigma = diag(2), mu, e, x0, lower.tail = TRUE, method_cdf = c('integrate', 'saddlepoint')) qmvnEll(p, sigma = diag(2), mu, e, x0, lower.tail = TRUE, loUp=NULL, method_cdf = c('integrate', 'saddlepoint')) rmvnEll(n, sigma = diag(2), mu, e, x0, method = c('eigen', 'chol', 'cdf'), loUp=NULL, method_cdf = c('integrate', 'saddlepoint'))
r |
vector of radii for the offset ellipse defined by |
p |
vector of probabilities. |
n |
number of observations. If |
sigma |
true positive definite covariance matrix of multivariate normal distribution. |
mu |
true center of multivariate normal distribution. |
e |
positive definite matrix characterizing the offset ellipse defined by (x-x0)' e (x-x0) < r^2. If the ellipse defined by |
x0 |
center of the offset ellipse. |
method |
string indicating which method to use for generating random deviates. See details. |
loUp |
search interval for numerical root finding. Either a vector with the lower and upper interval boundary, a list of such vectors, or an (n x 2)-matrix. See details. |
lower.tail |
logical. If |
method_cdf |
string indicating which method to use for calculating the sum of non-central chi^2 variables. See details. |
pmvnEll
is implemented by first transforming the integration region to the unit disc/sphere, then decorrelating the normal distribution through rotation. Finally, the quadratic form (sum of non-central chi^2 variables) is calculated depending on method_cdf
. For method_cdf='integrate'
, numerical integration using farebrother
is chosen, for method_cdf='saddlepoint'
, Kuonen's (1999) saddlepoint approximation. Note that the equation for the cumulant generating function K has a missing zeta in the numerator of the second term in Kuonen (1999), see Imhof (1961) instead. Lower tail probabilities are calculated as '1 - upper tail probability', so loss of accuracy is likely when the upper tail probability is very small (<1e-9).
qmvnEll
is implemented through numerical root finding of pmvnEll
. If no search interval for uniroot
is provided, the quantiles of an approximating non-central chi^2 distribution are used to determine the search intervals.
rmvnEll
with method='eigen'
or with method='chol'
simulates 2D normal deviates based on sigma
and mu
, and then determines the radius around x0
. rmvnEll
with method='cdf'
is much slower as it performs numerical root finding of pmvnEll
given simulated quantiles from a uniform random variable in (0,1). If no search interval for uniroot
is provided, the quantiles of an approximating non-central chi^2 distribution are used to determine the search intervals.
See Hoyt
for the distribution of radial error around the true center of correlated bivariate normal variables with unequal variances. See Rice
for the distribution of radial error around an offset center for uncorrelated bivariate normal variables with equal variances. See Rayleigh
for the distribution of radial error around the true center of uncorrelated bivariate normal variables with equal variances.
pmvnEll
integrates the multivariate normal distribution over an arbitrary ellipsoid and thus gives the cumulative distribution function. qmvnEll
gives the quantile function, rmvnEll
generates random deviates.
The functions are vectorized in r
and p
but not in the remaining parameters.
DiDonato, A. R., & Jarnagin, M. P. (1961a). Integration of the general bivariate Gaussian distribution over an offset circle. Mathematics of Computation, 15 (76), 375-382.
DiDonato, A. R., & Jarnagin, M. P. (1961b). Integration of the general bivariate Gaussian distribution over an offset ellipse (NWL TR 1710). Dahlgren, VA: U.S. Naval Weapons Laboratory.
Duchesne, P., & Lafaye de Micheaux, P. (2010). Computing the distribution of quadratic forms: Further comparisons between the Liu-Tang-Zhang approximation and exact methods. Computational Statistics and Data Analysis, 54, 858-862.
Imhof, J. P. (1961). Computing the distribution of quadratic forms in normal variables. Biometrika, 48, 419-426.
Kuonen D. (1999). Saddlepoint Approximations for Distributions of Quadratic Forms in Normal Variables. Biometrika, 86, 929-935.
# define a bivariate normal distribution mu <- c(2, -1) # true mean sigma <- cbind(c(10, 6), c(6, 10)) # covariance matrix # define circular integration region ctr <- c(1, 0) # center e1 <- diag(2) # circle r <- 2 # radius pmvnEll(r, sigma=sigma, mu=mu, e=e1, x0=ctr) # probability qmvnEll(0.5, sigma=sigma, mu=mu, e=e1, x0=ctr) # quantile rmvnEll(5, sigma=sigma, mu=mu, e=e1, x0=ctr) # random numbers # define elliptical integration region S <- cbind(c(3.5, -0.3), c(-0.3, 1.7)) e2 <- solve(S) pmvnEll(r, sigma=sigma, mu=mu, e=e2, x0=ctr) # probability qmvnEll(0.5, sigma=sigma, mu=mu, e=e2, x0=ctr) # quantile rmvnEll(5, sigma=sigma, mu=mu, e=e2, x0=ctr) # random numbers # plot all regions evSig <- eigen(sigma)$values evS <- eigen(S)$values xLims <- range(c( mu[1]+c(-1, 1)*sqrt(evSig[1]), ctr[1]+c(-r, r)*sqrt(evS[1]))) yLims <- range(c( mu[2]+c(-1.25, 1.25)*sqrt(evSig[1]), ctr[2]+c(-r, r)*sqrt(evS[1]))) plot(xLims, yLims, type="n", asp=1) points(mu[1], mu[2], pch=16, cex=2, col="black") points(ctr[1], ctr[2], pch=15, cex=2, col="blue") drawEllipse(mu, sigma, r=0.75, fg="black") drawEllipse(mu, sigma, r=1, fg="black") drawEllipse(mu, sigma, r=1.25, fg="black") drawEllipse(mu, sigma, r=1.5, fg="black") drawEllipse(ctr, e1, r=r, fg="blue") drawEllipse(ctr, S, r=r, fg="red") legend(x="bottomright", legend=c("normal iso-densities", "integration circle", "integration ellipse"), lty=1, col=c("black", "blue", "red"))
# define a bivariate normal distribution mu <- c(2, -1) # true mean sigma <- cbind(c(10, 6), c(6, 10)) # covariance matrix # define circular integration region ctr <- c(1, 0) # center e1 <- diag(2) # circle r <- 2 # radius pmvnEll(r, sigma=sigma, mu=mu, e=e1, x0=ctr) # probability qmvnEll(0.5, sigma=sigma, mu=mu, e=e1, x0=ctr) # quantile rmvnEll(5, sigma=sigma, mu=mu, e=e1, x0=ctr) # random numbers # define elliptical integration region S <- cbind(c(3.5, -0.3), c(-0.3, 1.7)) e2 <- solve(S) pmvnEll(r, sigma=sigma, mu=mu, e=e2, x0=ctr) # probability qmvnEll(0.5, sigma=sigma, mu=mu, e=e2, x0=ctr) # quantile rmvnEll(5, sigma=sigma, mu=mu, e=e2, x0=ctr) # random numbers # plot all regions evSig <- eigen(sigma)$values evS <- eigen(S)$values xLims <- range(c( mu[1]+c(-1, 1)*sqrt(evSig[1]), ctr[1]+c(-r, r)*sqrt(evS[1]))) yLims <- range(c( mu[2]+c(-1.25, 1.25)*sqrt(evSig[1]), ctr[2]+c(-r, r)*sqrt(evS[1]))) plot(xLims, yLims, type="n", asp=1) points(mu[1], mu[2], pch=16, cex=2, col="black") points(ctr[1], ctr[2], pch=15, cex=2, col="blue") drawEllipse(mu, sigma, r=0.75, fg="black") drawEllipse(mu, sigma, r=1, fg="black") drawEllipse(mu, sigma, r=1.25, fg="black") drawEllipse(mu, sigma, r=1.5, fg="black") drawEllipse(ctr, e1, r=r, fg="blue") drawEllipse(ctr, S, r=r, fg="red") legend(x="bottomright", legend=c("normal iso-densities", "integration circle", "integration ellipse"), lty=1, col=c("black", "blue", "red"))
Estimate the circular error probable (CEP) based on range statistics such as extreme spread, figure of merit, or the bounding box diagonal. This function assumes a circular bivariate normal shot distribution with 0 mean.
range2CEP(x, stat="ES", n=5, nGroups=1, CEPlevel=0.5, CIlevel=0.95, collapse=TRUE, dstTarget, conversion)
range2CEP(x, stat="ES", n=5, nGroups=1, CEPlevel=0.5, CIlevel=0.95, collapse=TRUE, dstTarget, conversion)
x |
a numerical vector with values for extreme spread (ES), figure of merit (FoM), or the diagonal of the bounding box (D). |
stat |
a character vector with elements |
n |
integer between 2 and 100. Number of shots in each group. |
nGroups |
integer between 1 and 10. Number of groups when |
CEPlevel |
a numerical vector with the coverage values for the CEP. |
CIlevel |
confidence level (coverage probability) for the CEP confidence interval. If one of |
collapse |
logical: should the list with CIs be simplified if possible? |
dstTarget |
a numerical value giving the distance to the target - used in MOA calculation. See |
conversion |
how to convert the measurement unit for distance to target to that of the (x,y)-coordinates in MOA calculation. Example |
Based on the lookup table DFdistr
with results form a Monte Carlo simulation. The Rayleigh sigma parameter is estimated using range2sigma
, and then converted to CEP with qRayleigh
.
If package shiny
is installed, an interactive web app for this functionality can be run with runGUI("range")
.
A list with the calculated CEP values in one component, and the corresponding CIs in the other component.
CEP |
The calculated CEP values in the original measurement unit as well as in angular size measures. |
CEPCI |
The calculated CEP CIs in the original measurement unit as well as in angular size measures. |
Taylor, M. S., & Grubbs, F. E. (1975). Approximate Probability Distributions for the Extreme Spread (BRL-MR-2438). Aberdeen Proving Ground, MD: U.S. Ballistic Research Laboratory.
DFdistr
,
range2sigma
qRayleigh
getCEP
es <- getMaxPairDist(DFscar17)$d fom <- getBoundingBox(DFscar17)$FoM d <- getBoundingBox(DFscar17)$diag range2CEP(c(es, fom, d), stat=c("ES", "FoM", "D"), n=nrow(DFscar17), nGroups=1, CEPlevel=0.5, CIlevel=0.9) # compare with Rayleigh CEP estimate from using # (x,y)-coordinates of all shots getCEP(DFscar17, CEPlevel=0.5, type="Rayleigh")
es <- getMaxPairDist(DFscar17)$d fom <- getBoundingBox(DFscar17)$FoM d <- getBoundingBox(DFscar17)$diag range2CEP(c(es, fom, d), stat=c("ES", "FoM", "D"), n=nrow(DFscar17), nGroups=1, CEPlevel=0.5, CIlevel=0.9) # compare with Rayleigh CEP estimate from using # (x,y)-coordinates of all shots getCEP(DFscar17, CEPlevel=0.5, type="Rayleigh")
Estimate the Rayleigh sigma parameter based on range statistics like extreme spread, figure of merit, or the bounding box diagonal. This function assumes a circular bivariate normal shot distribution with 0 mean.
range2sigma(x, stat="ES", n=5, nGroups=1, CIlevel=0.95, collapse=TRUE, dstTarget, conversion)
range2sigma(x, stat="ES", n=5, nGroups=1, CIlevel=0.95, collapse=TRUE, dstTarget, conversion)
x |
a numerical vector with values for extreme spread (ES), figure of merit (FoM), or the diagonal of the bounding box (D). |
stat |
a character vector with elements |
n |
integer between 2 and 100. Number of shots in each group. |
nGroups |
integer between 1 and 10. Number of groups when |
CIlevel |
confidence level (coverage probability) for the Rayleigh sigma confidence interval. If one of |
collapse |
logical: should the list with CIs be simplified if possible? |
dstTarget |
a numerical value giving the distance to the target - used in MOA calculation. See |
conversion |
how to convert the measurement unit for distance to target to that of the (x,y)-coordinates in MOA calculation. Example |
Based on the lookup table DFdistr
with results form a Monte Carlo simulation. If the value of n
is not among those simulated (but is less than 100), a monotonic spline interpolation between the neighboring simulated values of the statistic's coefficient of variation is used.
For conversion to the circular error probable, see range2CEP
.
Details for the calculation can be found under
http://ballistipedia.com/index.php?title=Range_Statistics
If package shiny
is installed, an interactive web app for this functionality can be run with runGUI("range")
.
A list with the calculated values for sigma in one component, and the corresponding CIs in the other component.
sigma |
The calculated values for sigma in the original measurement unit as well as in angular size measures. |
sigmaCI |
The calculated CIs for sigma in the original measurement unit as well as in angular size measures. |
Taylor, M. S., & Grubbs, F. E. (1975). Approximate Probability Distributions for the Extreme Spread (BRL-MR-2438). Aberdeen Proving Ground, MD: U.S. Ballistic Research Laboratory.
DFdistr
,
range2CEP
,
efficiency
,
getRayParam
,
getMaxPairDist
,
getBoundingBox
es <- getMaxPairDist(DFscar17)$d fom <- getBoundingBox(DFscar17)$FoM d <- getBoundingBox(DFscar17)$diag range2sigma(c(es, fom, d), stat=c("ES", "FoM", "D"), n=nrow(DFscar17), nGroups=1, CIlevel=0.9) # compare with Rayleigh sigma estimate from using # (x,y)-coordinates of all shots getRayParam(DFscar17, level=0.9)
es <- getMaxPairDist(DFscar17)$d fom <- getBoundingBox(DFscar17)$FoM d <- getBoundingBox(DFscar17)$diag range2sigma(c(es, fom, d), stat=c("ES", "FoM", "D"), n=nrow(DFscar17), nGroups=1, CIlevel=0.9) # compare with Rayleigh sigma estimate from using # (x,y)-coordinates of all shots getRayParam(DFscar17, level=0.9)
Approximate cumulative distribution function, quantile function and random deviates of range statistics based on a lookup table generated by simulations. Includes extreme spread (ES), figure of merit (FoM), bounding box diagonal (D). This function assumes a circular bivariate normal shot distribution with 0 mean.
pRangeStat(q, sigma = 1, nPerGroup = 5, nGroups = 1, stat = c("ES", "FoM", "D"), lower.tail = TRUE, loUp) qRangeStat(p, sigma = 1, nPerGroup = 5, nGroups = 1, stat = c("ES", "FoM", "D"), method = c("linear", "spline"), lower.tail = TRUE) rRangeStat(n, sigma = 1, nPerGroup = 5, nGroups = 1, stat = c("ES", "FoM", "D"))
pRangeStat(q, sigma = 1, nPerGroup = 5, nGroups = 1, stat = c("ES", "FoM", "D"), lower.tail = TRUE, loUp) qRangeStat(p, sigma = 1, nPerGroup = 5, nGroups = 1, stat = c("ES", "FoM", "D"), method = c("linear", "spline"), lower.tail = TRUE) rRangeStat(n, sigma = 1, nPerGroup = 5, nGroups = 1, stat = c("ES", "FoM", "D"))
q |
vector of quantiles. |
p |
vector of probabilities. Must be within [0.005, 0.995]. |
n |
number of observations. Must be <= 100. If |
stat |
character string indicating the range statistic. One of |
nPerGroup |
integer between 2 and 100. Number of shots in each group. |
nGroups |
integer between 1 and 10. Number of groups. For |
sigma |
numeric value > 0 indicating the Rayleigh scale parameter (common standard deviation of the underlying normal distribution of each 2D-coordinate). See |
lower.tail |
logical. If |
method |
method for bivariate interpolation if both, |
loUp |
search interval for numerical root finding. A vector with the lower and upper interval boundary. See details. |
Based on the lookup table DFdistr
with results form a Monte Carlo simulation. If the value either for p
or for nPerGroup
is missing from the lookup table, a monotone spline interpolation between the neighboring simulated values is used.
pRangeStat
is implemented through numerical root finding of qRangeStat
. If no search interval for uniroot
is provided, whole interval of probabilities available in DFdistr
is used. NA
is returned for quantiles corresponding to probabilities outside of the available range.
pRangeStat
gives the cumulative distribution function, qRangeStat
gives the quantile function, rRangeStat
generates random deviates.
http://ballistipedia.com/index.php?title=Range_Statistics
DFdistr
,
range2sigma
,
Rayleigh
,
interp
,
mba.surf
,
(q45 <- pRangeStat(c(4, 5), sigma=1.5, n=5, nGroups=3, stat="ES")) # should be the 4 and 5 qRangeStat(q45, sigma=1.5, n=5, nGroups=3, stat="ES") rRangeStat(5, sigma=2, nPerGroup=5, nGroups=3, stat="D")
(q45 <- pRangeStat(c(4, 5), sigma=1.5, n=5, nGroups=3, stat="ES")) # should be the 4 and 5 qRangeStat(q45, sigma=1.5, n=5, nGroups=3, stat="ES") rRangeStat(5, sigma=2, nPerGroup=5, nGroups=3, stat="D")
Density, distribution function, quantile function, and random deviate generation for the Rayleigh distribution. The radius around the true mean in a bivariate uncorrelated normal random variable with equal variances, re-written in polar coordinates (radius and angle), follows a Rayleigh distribution.
dRayleigh(x, scale) pRayleigh(q, scale, lower.tail = TRUE) qRayleigh(p, scale, lower.tail = TRUE) rRayleigh(n, scale)
dRayleigh(x, scale) pRayleigh(q, scale, lower.tail = TRUE) qRayleigh(p, scale, lower.tail = TRUE) rRayleigh(n, scale)
x , q
|
vector of quantiles. |
p |
vector of probabilities. |
n |
number of observations. If |
scale |
vector of Rayleigh scale parameters (common standard deviation of the underlying normal distribution of each 2D-coordinate). |
lower.tail |
logical. If |
The parameter scale
may be determined with getRayParam
.
See Maxwell
for the distribution of radial error around the true center of uncorrelated trivariate normal variables with equal variances. See Hoyt
for the distribution of radial error around the true center of correlated bivariate normal variables with unequal variances. See Rice
for the distribution of radial error around an offset center for uncorrelated bivariate normal variables with equal variances. See mvnEll
for the distribution of radial error around an offset center for correlated normal variables with unequal variances.
dRayleigh
gives the density, pRayleigh
gives the cumulative distribution function, qRayleigh
gives the quantile function, rRayleigh
generates random deviates.
The length of the result is determined by n
for rRayleigh
, and is the maximum of the lengths of the numerical parameters for the other functions.
In dRayleigh
, pRayleigh
and qRayleigh
, the numerical parameters are recycled to the length of the result. Only the first element of the logical parameters is used. In rRayleigh
, only the first element of scale
is used.
https://reference.wolfram.com/language/ref/RayleighDistribution.html
getRayParam
,
Maxwell
,
Rice
,
Hoyt
,
mvnEll
dRayleigh(1, scale=10) pRayleigh(c(0.1, 0.5, 0.9), scale=10) qRayleigh(0.5, scale=c(5, 10, 15)) rRayleigh(5, scale=10)
dRayleigh(1, scale=10) pRayleigh(c(0.1, 0.5, 0.9), scale=10) qRayleigh(0.5, scale=c(5, 10, 15)) rRayleigh(5, scale=10)
Reads data from text files that have a similar structure to OnTarget PC/TDS output files, specifically from Taran. Several files can be read with one call.
readDataMisc(fPath = ".", fNames, fPat, combine = TRUE, dstTarget, conversion)
readDataMisc(fPath = ".", fNames, fPat, combine = TRUE, dstTarget, conversion)
fPath |
a character string containing the path to the folder with the data files, e.g. |
fNames |
a character vector containing the file names of the files that should be read in. |
fPat |
a character string containing the regular-expression that describes all names of files that should be read in. E.g., |
combine |
logical: combine the data into one big data frame with |
dstTarget |
a numerical value/vector giving the distance to the target - used in MOA calculation. Acts as override if variable |
conversion |
how to convert the measurement unit for distance to target to that of the (x,y)-coordinates in MOA calculation. Example |
If fNames
is provided, fPat
is ignored.
If neither fNames
nor fPat
is provided, and we are in interactive mode under Windows, files can be chosen interactively.
This function is basically a wrapper for read.table
and read.csv
.
The files need to be either comma-separated or whitespace-delimited, and have a header with the variable names. Variable names must not contain spaces. In order to be later used by functions analyzeGroup
or compareGroups
, coordinates for points of impact must be given with point.x
, point.y
, x
, y
, or ShotX
, ShotY
. Point of aim can be given with aim.x
, aim.y
, otherwise (0,0) will be assumed in analysis functions. Distance to target can be given with distance
, otherwise 100m will be assumed in analysis functions. Files should to contain the variable Group
if combineData
should be later used to combine them into one big data frame. There can only be exactly as many variable names as there are non-empty data-columns.
For reading in files exported from OnTarget PC 1.*, see readDataOT1
.
For reading in files exported from OnTarget PC 2.* or OnTarget TDS v3.*, see readDataOT2
.
With combine=FALSE
: a list of data frames, each from one file that was read in. This list can then be combined into one big data frame by combineData
.
file1 |
data frame containing data from the first file |
file2 |
data frame containing data from the second file |
... |
more data frames |
With combine=TRUE
: a combined data frame from combineData
.
read.table
,
regex
,
glob2rx
,
combineData
,
readDataOT1
,
readDataOT2
,
readDataSMT
,
readDataShotMarker
## Not run: fPath <- 'c:/folder/files' # folder with data files fileNam <- c('pts01.txt', 'pts02.txt') # desired files in that folder DFgroup <- readDataMisc(fPath, fNames=fileNam, combine=TRUE) ## alternatively, specify filename pattern for all files to be read in fPath <- 'c:/folder/otFiles' # folder with data files fPat <- '^pts[[:digit:]]{2}\\.txt$' # filename pattern DFgroup <- readDataMisc(fPath, fPat=pattern, combine=TRUE) ## End(Not run) ## result should look like this data(DFcm) head(DFcm)
## Not run: fPath <- 'c:/folder/files' # folder with data files fileNam <- c('pts01.txt', 'pts02.txt') # desired files in that folder DFgroup <- readDataMisc(fPath, fNames=fileNam, combine=TRUE) ## alternatively, specify filename pattern for all files to be read in fPath <- 'c:/folder/otFiles' # folder with data files fPat <- '^pts[[:digit:]]{2}\\.txt$' # filename pattern DFgroup <- readDataMisc(fPath, fPat=pattern, combine=TRUE) ## End(Not run) ## result should look like this data(DFcm) head(DFcm)
Reads in data from files exported by OnTarget PC v1.1*. Several files can be read with one call.
readDataOT1(fPath = ".", fNames, fPat, combine = TRUE, dstTarget, conversion)
readDataOT1(fPath = ".", fNames, fPat, combine = TRUE, dstTarget, conversion)
fPath |
a character string containing the path to the folder with the OnTarget PC output files. E.g., |
fNames |
a character vector containing the file names of the files that should be read in. |
fPat |
a character string containing the regular-expression that describes all names of files that should be read in. E.g., |
combine |
logical: combine the data into one big data frame with |
dstTarget |
a numerical value/vector giving the distance to the target - used in MOA calculation. Acts as override if variable |
conversion |
how to convert the measurement unit for distance to target to that of the (x,y)-coordinates in MOA calculation. Example |
If fNames
is provided, fPat
is ignored.
If neither fNames
nor fPat
is provided, and we are in interactive mode under Windows, files can be chosen interactively.
This function is basically a wrapper for read.delim
.
Output files need to be tab-delimited files from OnTarget PC v1.1*: 'Tools -> Export Point Data'. Files need a trailing tab in each row, and need to contain exactly the following variable names in this order: Project Title
, Group
, Ammunition
, Distance
, Aim X
, Aim Y
, Center X
, Center Y
, Point X
, Point Y
.
Tested with OnTarget PC v1.10.
For reading in files exported from OnTarget PC v2.* or OnTarget TDS v3.*, see readDataOT2
.
For reading in other text files, see readDataMisc
.
With combine=FALSE
: a list of data frames, each from one file that was read in. This list can then be combined into one big data frame by combineData
.
file1 |
data frame containing data from the first file |
file2 |
data frame containing data from the second file |
... |
more data frames |
With combine=TRUE
: a combined data frame from combineData
.
read.delim
,
regex
,
glob2rx
,
combineData
,
readDataOT2
,
readDataSMT
,
readDataShotMarker
,
readDataMisc
## Not run: # folder with OnTarget PC v1.1* output files fPath <- 'c:/folder/otFiles' fileNam <- c('pts01.txt', 'pts02.txt') # desired files in that folder DFgroup <- readDataOT1(fPath, fNames=fileNam) ## alternatively, specify filename pattern for all files to be read in fPath <- 'c:/folder/otFiles' # folder with data files fPat <- '^pts[[:digit:]]{2}\\.txt$' # filename pattern DFgroup <- readDataOT1(fPath, fPat=pattern) ## End(Not run) ## result should look like this data(DFcm) head(DFcm)
## Not run: # folder with OnTarget PC v1.1* output files fPath <- 'c:/folder/otFiles' fileNam <- c('pts01.txt', 'pts02.txt') # desired files in that folder DFgroup <- readDataOT1(fPath, fNames=fileNam) ## alternatively, specify filename pattern for all files to be read in fPath <- 'c:/folder/otFiles' # folder with data files fPat <- '^pts[[:digit:]]{2}\\.txt$' # filename pattern DFgroup <- readDataOT1(fPath, fPat=pattern) ## End(Not run) ## result should look like this data(DFcm) head(DFcm)
Reads in data from files exported by OnTarget PC v2.* or OnTarget TDS v3.*. Several files can be read with one call.
readDataOT2(fPath = ".", fNames, fPat, combine = TRUE, dstTarget, conversion)
readDataOT2(fPath = ".", fNames, fPat, combine = TRUE, dstTarget, conversion)
fPath |
a character string containing the path to the folder with the OnTarget PC/TDS output files, e.g. |
fNames |
a character vector containing the file names of the files that should be read in. |
fPat |
a character string containing the regular-expression that describes all names of files that should be read in. E.g., |
combine |
logical: combine the data into one big data frame with |
dstTarget |
a numerical value/vector giving the distance to the target - used in MOA calculation. Acts as override if variable |
conversion |
how to convert the measurement unit for distance to target to that of the (x,y)-coordinates in MOA calculation. Example |
If fNames
is provided, fPat
is ignored.
If neither fNames
nor fPat
is provided, and we are in interactive mode under Windows, files can be chosen interactively.
This function is basically a wrapper for read.csv
.
Output files need to be comma-separated files (file type .csv
) from OnTarget PC v2.* or OnTarget TDS v3.*: 'Tools -> Export Point Data'. Files need to contain exactly the following variable names in this order: Project Title
, Group
, Ammunition
, Distance
, Aim X
, Aim Y
, Center X
, Center Y
, Point X
, Point Y
, and optionally Velocity
.
Tested with OnTarget PC v2.10 and v2.28 as well as OnTarget TDS v3.71, v3.89, v6.09.
For reading in files exported from OnTarget PC v1.*, see readDataOT1
.
For reading in other text files, see readDataMisc
.
With combine=FALSE
: a list of data frames, each from one file that was read in. This list can then be combined into one big data frame by combineData
.
file1 |
data frame containing data from the first file |
file2 |
data frame containing data from the second file |
... |
more data frames |
With combine=TRUE
: a combined data frame from combineData
.
read.csv
,
regex
,
glob2rx
,
combineData
,
readDataOT1
,
readDataSMT
,
readDataShotMarker
,
readDataMisc
## Not run: # folder with OnTarget PC v2.* or OnTarget TDS v3.* output files fPath <- 'c:/folder/otFiles' fileNam <- c('pts01.csv', 'pts02.csv') # desired files in that folder DFgroup <- readDataOT2(fPath, fNames=fileNam, combine=TRUE) ## alternatively, specify filename pattern for all files to be read in fPath <- 'c:/folder/otFiles' # folder with data files fPat <- '^pts[[:digit:]]{2}\\.txt$' # filename pattern DFgroup <- readDataOT2(fPath, fPat=pattern, combine=TRUE) ## End(Not run) ## result should look like this data(DFcm) head(DFcm)
## Not run: # folder with OnTarget PC v2.* or OnTarget TDS v3.* output files fPath <- 'c:/folder/otFiles' fileNam <- c('pts01.csv', 'pts02.csv') # desired files in that folder DFgroup <- readDataOT2(fPath, fNames=fileNam, combine=TRUE) ## alternatively, specify filename pattern for all files to be read in fPath <- 'c:/folder/otFiles' # folder with data files fPat <- '^pts[[:digit:]]{2}\\.txt$' # filename pattern DFgroup <- readDataOT2(fPath, fPat=pattern, combine=TRUE) ## End(Not run) ## result should look like this data(DFcm) head(DFcm)
Reads in data from files exported by the ShotMarker e-target system. Either CSV files or backup files. Several files can be read with one call.
readDataShotMarker(fPath = ".", fNames, fPat, combine = TRUE)
readDataShotMarker(fPath = ".", fNames, fPat, combine = TRUE)
fPath |
a character string containing the path to the folder with the ShotMarker output files, e.g. |
fNames |
a character vector containing the file names of the files that should be read in. Can be either plain text CSV file(s) or complete |
fPat |
a character string containing the regular-expression that describes all names of files that should be read in. E.g., |
combine |
logical: combine the data into one big data frame with |
If fNames
is provided, fPat
is ignored.
If neither fNames
nor fPat
is provided, and we are in interactive mode under Windows, files can be chosen interactively.
For CSV files, this function is basically a wrapper for read.csv
. To read in backup files, package jsonlite
must be installed.
Output files can be comma-separated files (file type .csv
) from ShotMarker e-target.
Coordinates are stored in inch, distance is converted to yard.
With combine=FALSE
: a list of data frames, each from one file that was read in. This list can then be combined into one big data frame by combineData
.
file1 |
data frame containing data from the first file |
file2 |
data frame containing data from the second file |
... |
more data frames |
With combine=TRUE
: a combined data frame from combineData
.
read.csv
,
regex
,
glob2rx
,
combineData
,
readDataOT1
,
readDataOT2
,
readDataSMT
,
readDataMisc
## Not run: # folder with Silver Mountain e-target output files fPath <- 'c:/folder/smtFiles' fileNam <- c('pts01.csv', 'pts02.csv') # desired files in that folder DFgroup <- readDataShotMarker(fPath, fNames=fileNam, combine=TRUE) ## alternatively, specify filename pattern for all files to be read in fPath <- 'c:/folder/smtFiles' # folder with data files fPat <- '^pts[[:digit:]]{2}\\.csv$' # filename pattern DFgroup <- readDataShotMarker(fPath, fPat=pattern, combine=TRUE) ## End(Not run) ## result should look like this data(DFcm) head(DFcm)
## Not run: # folder with Silver Mountain e-target output files fPath <- 'c:/folder/smtFiles' fileNam <- c('pts01.csv', 'pts02.csv') # desired files in that folder DFgroup <- readDataShotMarker(fPath, fNames=fileNam, combine=TRUE) ## alternatively, specify filename pattern for all files to be read in fPath <- 'c:/folder/smtFiles' # folder with data files fPat <- '^pts[[:digit:]]{2}\\.csv$' # filename pattern DFgroup <- readDataShotMarker(fPath, fPat=pattern, combine=TRUE) ## End(Not run) ## result should look like this data(DFcm) head(DFcm)
Reads in data from CSV files exported by the Silver Mountain e-target system. Several files can be read with one call.
readDataSMT(fPath = ".", fNames, fPat, combine = TRUE)
readDataSMT(fPath = ".", fNames, fPat, combine = TRUE)
fPath |
a character string containing the path to the folder with the SMT output files, e.g. |
fNames |
a character vector containing the file names of the files that should be read in. |
fPat |
a character string containing the regular-expression that describes all names of files that should be read in. E.g., |
combine |
logical: combine the data into one big data frame with |
If fNames
is provided, fPat
is ignored.
If neither fNames
nor fPat
is provided, and we are in interactive mode under Windows, files can be chosen interactively.
This function is basically a wrapper for read.csv
.
Output files need to be comma-separated files (file type .csv
) from Silver Mountain e-target. Files need to contain exactly the following variable names in this order: string
, shooter
, frame
, distance
, date
, score
, moa_x
, moa_y
, scope_x
, scope_y
, adj_x
, adj_y
, v
, adj_y_avg
, adj_y_sd
, v_avg
, v_sd
.
Coordinates are converted from MOA to inch, distance is converted from meter to yard.
For reading in other text files, see readDataMisc
.
With combine=FALSE
: a list of data frames, each from one file that was read in. This list can then be combined into one big data frame by combineData
.
file1 |
data frame containing data from the first file |
file2 |
data frame containing data from the second file |
... |
more data frames |
With combine=TRUE
: a combined data frame from combineData
.
read.csv
,
regex
,
glob2rx
,
combineData
,
readDataOT1
,
readDataOT2
,
readDataShotMarker
,
readDataMisc
## Not run: # folder with Silver Mountain e-target output files fPath <- 'c:/folder/smtFiles' fileNam <- c('pts01.csv', 'pts02.csv') # desired files in that folder DFgroup <- readDataSMT(fPath, fNames=fileNam, combine=TRUE) ## alternatively, specify filename pattern for all files to be read in fPath <- 'c:/folder/smtFiles' # folder with data files fPat <- '^pts[[:digit:]]{2}\\.csv$' # filename pattern DFgroup <- readDataSMT(fPath, fPat=pattern, combine=TRUE) ## End(Not run) ## result should look like this data(DFcm) head(DFcm)
## Not run: # folder with Silver Mountain e-target output files fPath <- 'c:/folder/smtFiles' fileNam <- c('pts01.csv', 'pts02.csv') # desired files in that folder DFgroup <- readDataSMT(fPath, fNames=fileNam, combine=TRUE) ## alternatively, specify filename pattern for all files to be read in fPath <- 'c:/folder/smtFiles' # folder with data files fPat <- '^pts[[:digit:]]{2}\\.csv$' # filename pattern DFgroup <- readDataSMT(fPath, fPat=pattern, combine=TRUE) ## End(Not run) ## result should look like this data(DFcm) head(DFcm)
Density, distribution function, quantile function, and random deviate generation for the Rice distribution. The radius around the origin in a bivariate uncorrelated normal random variable with equal variances and an offset mean, re-written in polar coordinates (radius and angle), follows a Rice distribution.
dRice(x, nu, sigma) pRice(q, nu, sigma, lower.tail = TRUE) qRice(p, nu, sigma, lower.tail = TRUE) rRice(n, nu, sigma, method = c('eigen', 'chol', 'cdf'))
dRice(x, nu, sigma) pRice(q, nu, sigma, lower.tail = TRUE) qRice(p, nu, sigma, lower.tail = TRUE) rRice(n, nu, sigma, method = c('eigen', 'chol', 'cdf'))
x , q
|
vector of quantiles. |
p |
vector of probabilities. |
n |
number of observations. If |
nu |
vector of Rice shape parameters nu. See details. |
sigma |
vector of Rice scale parameter sigma. See details. |
method |
string indicating which method to use for generating random deviates. See details. |
lower.tail |
logical. If |
dRice
involves the modified Bessel function of the first kind and order 0. pRice
and qRice
are implemented using the Marcum Q-function. The Marcum Q-function is the cdf of a non-central chi^2 variable (Nuttall, 1975).
rRice
with method='eigen'
or with method='chol'
simulates 2D normal deviates based on the diagonal covariance matrix with entries sigma
^2, and then determines the radius. rRice
with method='cdf'
uses qRice
with simulated quantiles from a uniform random variable in (0,1).
See Hoyt
for the distribution of radial error around the true center of correlated bivariate normal variables with unequal variances. See Rayleigh
for the distribution of radial error around the true center of uncorrelated bivariate normal variables with equal variances. See mvnEll
for the distribution of radial error around an offset center for correlated normal variables with unequal variances.
For very large signal-to-noise ratios (nu/sigma), a normal approximation is used.
dRice
gives the density, pRice
gives the cumulative distribution function, qRice
gives the quantile function, rRice
generates random deviates.
The length of the result is determined by n
for rRice
, and is the maximum of the lengths of the numerical parameters for the other functions.
In dRice
, pRice
and qRice
, the numerical parameters are recycled to the length of the result. Only the first element of the logical parameters is used. In rRice
, only the first element of nu
and sigma
is used.
Nuttall, AH. (1975). Some integrals involving the Q-M function. IEEE Transactions on Information Theory, 21 (1), 95-96
https://reference.wolfram.com/language/ref/RiceDistribution.html
Rayleigh
,
Hoyt
,
mvnEll
,
Bessel
,
Chisquare
,
uniroot
dRice(1, nu=c(0.1, 0.5, 0.9), sigma=10) pRice(c(0.1, 0.5, 0.9), nu=0.5, sigma=10) qRice(0.5, nu=0.5, sigma=c(5, 10, 15)) rRice(5, nu=0.5, sigma=10)
dRice(1, nu=c(0.1, 0.5, 0.9), sigma=10) pRice(c(0.1, 0.5, 0.9), nu=0.5, sigma=10) qRice(0.5, nu=0.5, sigma=c(5, 10, 15)) rRice(5, nu=0.5, sigma=10)
Opens one of four web-based GUIs for shotGroups
functionality in an external browser.
runGUI(app=c("analyze", "hitprob", "range", "angular"), ...)
runGUI(app=c("analyze", "hitprob", "range", "angular"), ...)
app |
character string. One of |
... |
arguments passed to |
Requires installing package shiny
first. This function calls runApp
to run the included shotGroupsApp application.
## Not run: runGUI(app="analzye") ## End(Not run)
## Not run: runGUI(app="analzye") ## End(Not run)
Calculates the simulated ring count given a group, bullet diameter, and target type.
simRingCount(xy, center = FALSE, target, caliber, unit = 'cm') ## S3 method for class 'data.frame' simRingCount(xy, center = FALSE, target, caliber, unit = 'cm') ## Default S3 method: simRingCount(xy, center = FALSE, target, caliber, unit='cm')
simRingCount(xy, center = FALSE, target, caliber, unit = 'cm') ## S3 method for class 'data.frame' simRingCount(xy, center = FALSE, target, caliber, unit = 'cm') ## Default S3 method: simRingCount(xy, center = FALSE, target, caliber, unit='cm')
xy |
either a numerical (n x 2)-matrix with the (x,y)-coordinates of n points (1 row of coordinates per point), or a data frame with either the variables |
center |
logical: center groups to mean (0,0) first? If variable |
target |
either a character value with the name of a target in |
caliber |
a numerical value indicating the bullet diameter in mm. |
unit |
measurement unit of the (x,y)-coordinates in |
The returned ring count assumes that bullet holes exactly have the diameter given by caliber
, and that rings exactly have the diameter/width given in the definition of target
. The count thus ignores the possibility of ragged bullet holes as well as the physical width of the ring markings. The simulated ring count therefore need not be equal to the calculated ring count from the corresponding physical target.
A list with the following components:
count |
the total ring count. |
max |
the maximum ring count achievable with the given number of shots. |
rings |
the individual ring count for each shot. |
simRingCount(DFscar17, target='ISSF_100m', caliber=5.56, unit='in') # ring count for all groups in DFcm data set rc <- by(DFcm, DFcm$series, FUN=simRingCount, target='BDS9', caliber=9, unit='cm') sapply(rc, function(x) with(x, c(count=count, max=max)))
simRingCount(DFscar17, target='ISSF_100m', caliber=5.56, unit='in') # ring count for all groups in DFcm data set rc <- by(DFcm, DFcm$series, FUN=simRingCount, target='BDS9', caliber=9, unit='cm') sapply(rc, function(x) with(x, c(count=count, max=max)))
List containing definitions of several circular german (DSB, BDS, BDMP, DSU), ISSF, and NRA target types.
data(targets)
data(targets)
A list with the following components, each defining one target type.
ISSF_10mAR
ISSF 10m Air Rifle.
ISSF_10mAP
ISSF 10m Air Pistol.
ISSF_25mPP
ISSF 25m Precision Pistol, 50m Pistol.
ISSF_25mRFP
ISSF 25m Rapid Fire Pistol.
ISSF_50m
ISSF 50m Rifle.
ISSF_100m
ISSF 100m Rifle (same as ISSF_25mPP
).
ISSF_300m
ISSF 300m Rifle.
ISSF_25ydPP
ISSF 25m and 50m Precision Pistol target adapted to 25yd.
ISSF_50ydPP
ISSF 25m and 50m Precision Pistol target adapted to 50yd.
ISSF_50ftPP
ISSF 25m and 50m Precision Pistol target adapted to 50ft.
ISSF_50ftSP
ISSF 25m and 50m Precision Pistol target adapted to 50ft Sport Pistol.
ISSF_25ydRFP
ISSF 25m Rapid Fire Pistol target adapted to 25yd.
ISSF_50ftRFP
ISSF 25m Rapid Fire Pistol target adapted to 50ft.
ISSF_50ft
ISSF 50m Rifle target adapted to 50ft.
ISSF_50yd
ISSF 50m Rifle target adapted to 50yd.
ISSF_100yd
ISSF 300m Rifle target adapted to 100yd.
ISSF_200yd
ISSF 300m Rifle target adapted to 200yd.
ISSF_300yd
ISSF 300m Rifle target adapted to 300yd.
NRA_HPR_SR
NRA 200yd High Powered Rifle SR: Military Target, Rifle Competition, Short Range.
NRA_HPR_SR3
NRA 300yd High Powered Rifle SR-3.
NRA_P_B16
NRA 25yd Pistol Slow Fire B-16.
NRA_MR-1
NRA MR-1.
NRA_MR-1FC
NRA MR-1 F-class.
NRA_MR-63
NRA MR-63 300yd.
NRA_MR-63FC
NRA MR-63 F-class.
NRA_MR-65
NRA MR-65 500yd.
NRA_MR-65FC
NRA MR-65 F-class.
NRA_LR
NRA LR.
NRA_LRFC
NRA LR F-class.
DSB1
DSB 10m Luftgewehr (same as ISSF_10mAR
).
DSB2
DSB 15m Zimmerstutzen.
DSB3
DSB 50m Kleinkalibergewehr (same as ISSF_50m
).
DSB4
DSB 100m Kleinkalibergewehr, 25m Pistole-Praezision, 25m Standardpistole, 50m Pistole (same as ISSF_25mPP
).
DSB5
DSB 300m Gewehr/Vorderlader Freigewehr (same as ISSF_300m
).
DSB6
DSB 50m Muskete Luntenschlossgewehr.
DSB7
DSB 10m Luftpistole (same as ISSF_10mAP
).
DSB9
DSB 25m Schnellfeuerpistole, 25m Pistole Duell (same as ISSF_25mRFP
).
DSB11
DSB 10m Laufende Scheibe.
BDS1
BDS 100m.
BDS2
BDS 50m Zielfernrohr.
BDS3
BDS 50m (same as ISSF_50m
).
BDS4
BDS 100m Zielfernrohr.
BDS5
BDS Pistole 25m, Pistole 50m (same as ISSF_100m
).
BDS7
BDS 300m (same as ISSF_300m
).
BDS8
BDS 300m Zielfernrohr.
BDS9
BDS 25m Kurzwaffe.
BDS13
BDS 10m Luftgewehr (same as ISSF_10mAR
).
BDS14
BDS 10m Luftpistole (same as DSB7
).
BDMP1_25m
BDMP 25m .30 M1 Carbine.
BDMP1_50m
BDMP 50m .30 M1 Carbine.
BDMP1_100m
BDMP 100m SG 1, CISM-Gewehr, .30 M1 Carbine.
BDMP2
BDMP 300m SG 2, CISM-Gewehr, DG 2, FG 1, PVDG 1, PHDG 1, SDG 1, SDG 2, PFG 1, SPPDG 1 (same as ISSF_300m
).
BDMP3
BDMP ZG 1.
BDMP4
BDMP ZG 2, ZG 3, ZG 4.
BDMP5
BDMP 300m DG 3, DG 4.
DSUa2
DSU a2.
DSUb2
DSU b2.
DSUb3
DSU b3.
DSUb4
DSU b4.
DSUb5
DSU b5.
DSUb5P
DSU b5 Praezision.
DSU_200mP
DSU 200m Praezision.
DSU_UITP
DSU UIT Praezision (same as ISSF_100m
).
DSU_KKI
DSU KK international (same as ISSF_50m
).
Each target is defined by (at least) the following parameters
name
: target name
unitTarget
: measurement unit for ring diameters and radii
nRings
: number of rings
maxCount
: highest ring count for scoring
ringD10
: diameter of ring number 10 (highest-valued ring)
ringD10i
: diameter of sub-division of ring number 10 (Innenzehn). If target has no sub-division, equal to ringD10
ringW
: width of the remaining rings number 9, 8, 7, ...
cols
: nRings
+1 colors of the rings - right half of the target, starting with the sub-division of ring number 10 and going outwards
colsTxt
: nRings
-1 colors of the ring numbers, starting with ring number 9 and going outwards
A target may have more parameters, e.g., draw
to indicate the drawing function that should be used, or countMouche
if the inner 10 (mouche) should be counted extra in scoring.
data(targets) names(targets) targets$ISSF_25mPP
data(targets) names(targets) targets$ISSF_25mPP