because I actually need the result for later computations. Look again at my runtime_test!
function:
function runtime_test!(rez,slack,D)
n = length(rez)
N = length(D)
rez[1] = exp_and_mean!(slack,D,N)
for i in 1:n-1
rez[i+1] = prod_and_mean!(slack,D,N)
end
return rez
end
You see that the slack is passed along from one function to the other. Actually, if you denote by X the rndom variable that corresponds to the data D
, my function computes \mathbb E\left(X^k e^{-X}\right), for k \in \{0,...,n-1\}.
No there is no error in “prod_and_mean”, I indeed mean to sum zz
. Yes this is intended, since slack
is not expected to be zeros when calling the prod_and_mean
function, look again at the runtime_test!
function
I do not understand what you mean. This computation is done only once for a given dataset D
, I am afraid. The dataset D
changes from one execution to the next, albeit not completely randomly: I compute it from another dataset data
as follows:
data=.... #(sized (10,10000)
for i in 1:n_iterations
e = rand(10) # A new one is picked at each iteration
D = data'e # now a vector of size 10000
runtime_test!(rez,slack,D)
do_something_with!(rez)
end
data
is fixed from one iteration to the other, but e
is not (and therefore neither D
, slack
and rez
). rez
is needed for the rest of the computations, but D
and slack
are not.