Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@
* `get_input_data`, `get_output_data`, `get_prior_model`: Removed
(these getters were already deprecated, cf. STK 2.6.0 release notes).

## Simulation

* `stk_generate_samplepaths`: the syntaxes with arguments XI, ZI
(conditional simulations) are deprecated; use a posterior model
object instead.

## Arrays

* `stk_dataframe` arrays now possess a `sample_size` property, which
Expand Down
33 changes: 32 additions & 1 deletion admin/octpkg/INDEX
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ Simulations
#@stk_model_/stk_predict_ [internal]
#@stk_model_/stk_covmat_noise [overload STK]
#@stk_model_/stk_get_input_data [overload STK]
#@stk_model_/stk_get_input_dim [overload STK]
#@stk_model_/stk_get_output_data [overload STK]
#@stk_model_/stk_get_output_dim [overload STK]
#@stk_model_/stk_get_prior_model [overload STK]
#@stk_model_/stk_get_sample_size [overload STK]
#@stk_model_/stk_get_observation_variances [overload STK]
Expand All @@ -106,26 +108,50 @@ Simulations

Get/set model properties
stk_get_input_data
stk_get_input_dim
stk_get_output_data
stk_get_output_dim
stk_get_prior_model
stk_get_observation_variances
stk_isnoisy
#stk_set_optimizable_model_parameters [internal]
#stk_get_optimizable_model_parameters [internal]
#stk_get_optimizable_noise_parameters [internal]

Input/output data: the @stk_iodata class
@stk_iodata/stk_iodata
@stk_iodata/stk_get_input_data
@stk_iodata/stk_get_input_dim
@stk_iodata/stk_get_output_data
@stk_iodata/stk_get_output_dim
@stk_iodata/stk_get_output_nrep
@stk_iodata/stk_get_output_var
@stk_iodata/stk_get_sample_size
@stk_iodata/stk_normalize_input_data
@stk_iodata/stk_normalize_output_data
@stk_iodata/stk_update
#@stk_iodata/stk_warn_about_constant_response [internal]
#@stk_iodata/stk_assert_no_duplicates [overload STK]
#@stk_iodata/stk_sprintf_sizetype [overload STK]
#@stk_iodata/disp [overload base]
#@stk_iodata/display [overload base]
#@stk_iodata/get [overload base]
#@stk_iodata/set [overload base]
#@stk_iodata/subsasgn [overload base]
#@stk_iodata/subsref [overload base]

Posterior model objects
@stk_model_gpposterior/stk_model_gpposterior
@stk_model_gpposterior/stk_predict_leaveoneout
@stk_model_gpposterior/stk_model_update
#@stk_model_gpposterior/stk_covmat_noise [overload STK]
#@stk_model_gpposterior/stk_isnoisy [overload STK]
#@stk_model_gpposterior/stk_generate_samplepaths [overload STK]
#@stk_model_gpposterior/stk_get_observation_variances [overload STK]
#@stk_model_gpposterior/stk_get_optimizable_parameters [overload STK]
#@stk_model_gpposterior/stk_set_optimizable_parameters [overload STK]
#@stk_model_gpposterior/stk_get_optimizable_noise_parameters [overload STK]
#@stk_model_gpposterior/stk_get_input_data [overload STK]
#@stk_model_gpposterior/stk_get_input_dim [overload STK]
#@stk_model_gpposterior/stk_get_output_data [overload STK]
#@stk_model_gpposterior/stk_get_prior_model [overload STK]
#@stk_model_gpposterior/stk_get_sample_size [overload STK]
Expand Down Expand Up @@ -549,6 +575,7 @@ Miscellaneous: unit tests
#stk_test_class [internal]
#stk_test_dfbinaryop [internal]
#stk_test_critgrad [internal]
#stk_process_data_arg [internal]

## misc/text
#stk_disp_examplewelcome [internal]
Expand Down Expand Up @@ -589,3 +616,7 @@ Miscellaneous: unit tests
#stk_param_estim_withrep [experimental]
#stk_predict_withrep [experimental]
#stk_quadrature [experimental]

## TEMP (iodata branch)
#essai_stk_iodata
#likelihood_challenge
2 changes: 2 additions & 0 deletions arrays/@stk_dataframe/stk_get_sample_size.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
% STK_GET_SAMPLE_SIZE [overload STK function]
%
% See also: stk_get_sample_size

% Copyright Notice
%
Expand Down
33 changes: 33 additions & 0 deletions arrays/@stk_iodata/disp.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
% DISP [overload base function]

% Copyright Notice
%
% Copyright (C) 2015 CentraleSupelec
%
% Author: Julien Bect <julien.bect@centralesupelec.fr>

% Copying Permission Statement
%
% This file is part of
%
% STK: a Small (Matlab/Octave) Toolbox for Kriging
% (http://sourceforge.net/projects/kriging)
%
% STK is free software: you can redistribute it and/or modify it under
% the terms of the GNU General Public License as published by the Free
% Software Foundation, either version 3 of the License, or (at your
% option) any later version.
%
% STK is distributed in the hope that it will be useful, but WITHOUT
% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
% or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
% License for more details.
%
% You should have received a copy of the GNU General Public License
% along with STK. If not, see <http://www.gnu.org/licenses/>.

function disp (data)

disp (struct (data));

end % function
37 changes: 37 additions & 0 deletions arrays/@stk_iodata/display.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
% DISPLAY [overload base function]

% Copyright Notice
%
% Copyright (C) 2015 CentraleSupelec
%
% Author: Julien Bect <julien.bect@centralesupelec.fr>

% Copying Permission Statement
%
% This file is part of
%
% STK: a Small (Matlab/Octave) Toolbox for Kriging
% (http://sourceforge.net/projects/kriging)
%
% STK is free software: you can redistribute it and/or modify it under
% the terms of the GNU General Public License as published by the Free
% Software Foundation, either version 3 of the License, or (at your
% option) any later version.
%
% STK is distributed in the hope that it will be useful, but WITHOUT
% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
% or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
% License for more details.
%
% You should have received a copy of the GNU General Public License
% along with STK. If not, see <http://www.gnu.org/licenses/>.

function display (data)

fprintf ('\n%s = <%s>\n\n', inputname (1), stk_sprintf_sizetype (data));

disp (data);

fprintf ('\n');

end % function
37 changes: 37 additions & 0 deletions arrays/@stk_iodata/get.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
% GET [overload base function]

% Copyright Notice
%
% Copyright (C) 2019 CentraleSupelec
%
% Author: Julien Bect <julien.bect@centralesupelec.fr>

% Copying Permission Statement
%
% This file is part of
%
% STK: a Small (Matlab/Octave) Toolbox for Kriging
% (http://sourceforge.net/projects/kriging)
%
% STK is free software: you can redistribute it and/or modify it under
% the terms of the GNU General Public License as published by the Free
% Software Foundation, either version 3 of the License, or (at your
% option) any later version.
%
% STK is distributed in the hope that it will be useful, but WITHOUT
% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
% or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
% License for more details.
%
% You should have received a copy of the GNU General Public License
% along with STK. If not, see <http://www.gnu.org/licenses/>.

function value = get (data, propname)

if ~ ischar (propname)
stk_error ('Invalid property name.', 'InvalidArgument');
end

value = data.(propname);

end % function
111 changes: 111 additions & 0 deletions arrays/@stk_iodata/private/gather_repetitions_inside.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
% GATHER_REPETITIONS_INSIDE [STK internal]

% Copyright Notice
%
% Copyright (C) 2015, 2019, 2020 CentraleSupelec
%
% Author: Julien Bect <julien.bect@supelec.fr>

% Copying Permission Statement
%
% This file is part of
%
% STK: a Small (Matlab/Octave) Toolbox for Kriging
% (http://sourceforge.net/projects/kriging)
%
% STK is free software: you can redistribute it and/or modify it under
% the terms of the GNU General Public License as published by the Free
% Software Foundation, either version 3 of the License, or (at your
% option) any later version.
%
% STK is distributed in the hope that it will be useful, but WITHOUT
% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
% or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
% License for more details.
%
% You should have received a copy of the GNU General Public License
% along with STK. If not, see <http://www.gnu.org/licenses/>.

function [x, zm, zv, nrep] = gather_repetitions_inside (x, zm, zv, nrep)

sample_size = size (x, 1);

[ignd, idx, pos] = unique (x, 'rows', 'first'); %#ok<ASGLU> CG#07
nb_unique = length (idx);

% Stop here if there are no repetitions
if nb_unique == sample_size
return
end

% Prepare to gather repetitions
if isempty (nrep)
nrep = ones (sample_size, 1);
end
if isempty (zv)
zv = zeros (sample_size, size (zm, 2));
end

% Note: Octave doesn't support the 'stable' option, so we just reorder manually
[idx_stable, k] = sort (idx);

% Keep unique input data only
x_out = x(idx_stable, :);

% Initialize outputs with inputs
% (this way, the output is already correct for the rows that are not repeated)
zm_out = zm(idx_stable, :);
zv_out = zv(idx_stable, :);
nrep_out = nrep(idx_stable);

% Loop over the rows of the output matrix
for r = 1:nb_unique
% * r: index of the row in the output data
% * k(r): index of the row in the "intermediate" data
% * idx_stable(r): index of the row in the input data

% Find which rows in the input are repetitions of x_out(r, :)
i_rep = find (pos == k(r));

% Count repetitions of x_out(r, :)
n_rep = length (i_rep); assert (n_rep > 0);

if n_rep > 1

% Keep relevant data only
zm_ = zm(i_rep, :);
zv_ = zv(i_rep, :);
nrep_ = nrep(i_rep);

% Total number of repetitions
nrep_out(r) = sum (nrep_);

% Prepare for computing weighted means
p = nrep_ / nrep_out(r);

% Batch mean (law of total expectation)
zm_out(r, :) = sum (bsxfun (@times, p, zm_));

% Batch variance (law of total variance)
dzm = bsxfun (@minus, zm_, zm_out(r, :));
zv_out(r, :) = ...
sum (bsxfun (@times, p, zv_)) + ...
sum (bsxfun (@times, p, dzm .^ 2));

% We can't preserve row names
if (isa (x_out, 'stk_dataframe')) && (~ isempty (x_out.rownames))
x_out.rownames{r} = '';
end
if (isa (zm_out, 'stk_dataframe')) && (~ isempty (zm_out.rownames))
zm_out.rownames{r} = '';
end

end
end

x = x_out;
zm = zm_out;
zv = zv_out;
nrep = nrep_out;

end % function
37 changes: 37 additions & 0 deletions arrays/@stk_iodata/set.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
% SET [overload base function]

% Copyright Notice
%
% Copyright (C) 2016 CentraleSupelec
%
% Author: Julien Bect <julien.bect@centralesupelec.fr>

% Copying Permission Statement
%
% This file is part of
%
% STK: a Small (Matlab/Octave) Toolbox for Kriging
% (http://sourceforge.net/projects/kriging)
%
% STK is free software: you can redistribute it and/or modify it under
% the terms of the GNU General Public License as published by the Free
% Software Foundation, either version 3 of the License, or (at your
% option) any later version.
%
% STK is distributed in the hope that it will be useful, but WITHOUT
% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
% or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
% License for more details.
%
% You should have received a copy of the GNU General Public License
% along with STK. If not, see <http://www.gnu.org/licenses/>.

function data = set (data, propname, value)

stk_error ('stk_iodata objects are immutable', 'ReadOnlyProperty');

% FIXME: Consider making rep_mode writeable (?).

end % function

%#ok<*INUSD>
38 changes: 38 additions & 0 deletions arrays/@stk_iodata/stk_assert_no_duplicates.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
% STK_ASSERT_NO_DUPLICATES [overload STK function]

% Copyright Notice
%
% Copyright (C) 2020 CentraleSupelec
%
% Author: Julien Bect <julien.bect@centralesupelec.fr>

% Copying Permission Statement
%
% This file is part of
%
% STK: a Small (Matlab/Octave) Toolbox for Kriging
% (http://sourceforge.net/projects/kriging)
%
% STK is free software: you can redistribute it and/or modify it under
% the terms of the GNU General Public License as published by the Free
% Software Foundation, either version 3 of the License, or (at your
% option) any later version.
%
% STK is distributed in the hope that it will be useful, but WITHOUT
% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
% or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
% License for more details.
%
% You should have received a copy of the GNU General Public License
% along with STK. If not, see <http://www.gnu.org/licenses/>.

function stk_assert_no_duplicates (data)

if strcmp (data.rep_mode, 'ignore')
stk_assert_no_duplicates (data.input_data);
end

% For the other modes ('forbid', 'gather') we already know
% that there are no duplicated inputs (otherwise, it's a bug).

end % function
Loading