-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: possible solution to allow bootstrapping form an arbitrary number of distributions #58
Conversation
Thanks for taking a shot at implement this. |
Thanks! Yes, I suppose it might be easier if we define separate methods that operate on a vector of multiple distributions. I was trying to come up with an implementation that didn't produce too much (approximately) duplicated code. Are you suggesting we do something more like this: # current implementation, remains as is
function bootstrap(statistic::Function, data, sampling::BasicSampling)
# ...
end
# new implementation that bootstraps from multiple distributions
function bootstrap(statistic::Function,
data::AbstractVector{<:AbstractVector{T}},
sampling::BasicSampling) where T
t0 = tx(statistic(data...))
m = nrun(sampling)
t1 = zeros_tuple(t0, m)
data1 = copy(data)
for i in 1:m
draw!.(data, data1)
for (j, t) in enumerate(tx(statistic(data1...)))
t1[j][i] = t
end
end
return NonParametricBootstrapSample(t0, t1, statistic, data, sampling)
end |
Please ignore what I said about the function bootstrap(statistic::Function, data, sampling::BasicSampling)
# same as before
end
function bootstrap(statistic::Function, data::Tuple, sampling::BasicSampling)
# new implementation that bootstraps from multiple distributions
# where `data::Tuple` represents different data sets
# e.g. (rand(10), rand(100))
end What do you think? |
Ahh I see, no problem about the misunderstanding. So the new method that would implement the boostrapping from multiple distributions would be something like: function bootstrap(statistic::Function, data::Tuple, sampling::BasicSampling)
t0 = tx(statistic(data...))
m = nrun(sampling)
t1 = zeros_tuple(t0, m)
data1 = copy.(data)
for i in 1:m
draw!.(data, data1)
for (j, t) in enumerate(tx(statistic(data1...)))
t1[j][i] = t
end
end
return NonParametricBootstrapSample(t0, t1, statistic, data, sampling)
end If so, I will have a go at implementing this for the other sampling strategies. |
What if we used your bootstrap(statistic::Function, data, sampling::BasicSampling) = bootstrap(statistic, tuple(data), sampling) Wouldn't that avoid most of the code duplication? It would affect how |
I think this is exactly how I implemented it in the commit on this PR. You're right that it does avoid code duplication. But it will require a bit of tinkering with existing code e.g. |
Is there still any interest in getting this feature working? |
This is one possible way to implement #51. Essentially we redefine the
bootstrap
method, that contains the main logic, to accept a tuple and then define a separate method that wraps any non-tuple input in a tuple. Currently this is a prototype and is only implemented forBasicSampling
. This allows the following:Would be interested in your thoughts!