[R] DescTools::Quantile

2024-01-26 Thread Michael Meyer via R-help
Greetings, I am having a problem with DescTools::Quantile (a function computing quantiles from weighted samples): # these sum to one probWeights = c( 0.0043, 0.0062, 0.0087, 0.0119, 0.0157, 0.0204, 0.0257, 0.0315, 0.0378, 0.0441, 0.0501, 0.0556, 0.06, 0.0632, 0.0648, 0.0648, 0.0632,

[R] Quantiles of sums of independent discrete random variables

2024-01-25 Thread Michael Meyer via R-help
Greetings, Minimal reproducible example as requested by the technical expert Jeff Newmiller: library(bayesmeta) # density of $(1/10)*\sum_{j=1}{10}N(j,0.01$ # (convex sum of normal distributions) # f <- Vectorize(function(s) sum(vapply(1:10,    FUN = function(j) dnorm(s,mean=j,sd=0.01)/10,

[R] Use of geometric mean .. in good data analysis

2024-01-25 Thread Michael Meyer via R-help
By the Strong Law of Large Numbers applied to log(X) the geometric mean of X_1,...,X_n > 0 and IID like X converges toexp(E[log(X)]] which, by Jensen's inequality, is always  <= E[X] and is strictly less than E[X] except in trivial extreme cases. In short: by using the geometric mean all

[R] Quantiles of sums of independent discrete random variables

2024-01-23 Thread Michael Meyer via R-help
Greetings, I have the following  Problem: Given k (=10) discrete independent random variables X_i with n_i (= 5 to 20) values each,compute quantiles of the distribution of the sum X = X_1+...+X_k. Here X has n=n_1 x n_2 ... n_k distinct values which is too large to list them all together with

[R] Rcpp, function signature

2015-08-27 Thread Michael Meyer via R-help
Greetings, I am an (very) grateful user of Rcpp. As such I defined a function // [[Rcpp::export]] NumericVector leftShift(NumericVector x){ for(int i=0;in-1;i++) x[i]=x[i+1]; return x; } expecting this function not to affect the parameter x outside the function body as it is passed in by