Skip to content

Commit

Permalink
move up mapparams_generic
Browse files Browse the repository at this point in the history
  • Loading branch information
ofrei committed May 23, 2019
1 parent f325aa2 commit abfa1d3
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions BGMG_cpp_fit_bivariate.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
if ~isnan(options.TolX), fminsearch_options.MaxFunEvals=options.TolX; end;
if ~isnan(options.TolFun), fminsearch_options.MaxFunEvals=options.TolFun; end;

mapparams_generic = @(x, params0)BGMG_util.BGMG_mapparams3_rho_and_pifrac(x, struct(...
'sig2_zero', params0.sig2_zero, ...
'sig2_beta', params0.sig2_beta(:, end), ...
'pi_vec', [sum(params0.pi_vec([1, 3])), sum(params0.pi_vec([2, 3]))]));

params1.pi_vec = sum(params.pi_vec([1, 3]));
params2.pi_vec = sum(params.pi_vec([2, 3]));
params_inft.rho_beta = params.rho_beta(3) * params.pi_vec(3)/sqrt(params1.pi_vec*params2.pi_vec); % rg
Expand All @@ -28,10 +33,6 @@
max_rg = max_pi12/sqrt(params1.pi_vec * params2.pi_vec);
if ((abs(params_inft.rho_beta) > abs(max_rg)) || (min_pi12 > max_pi12)) % mathematically these two conditions are equivalent
% backup solution for the case when rg is too large...
mapparams_generic = @(x, params0)BGMG_util.BGMG_mapparams3_rho_and_pifrac(x, struct(...
'sig2_zero', params0.sig2_zero, ...
'sig2_beta', params0.sig2_beta(:, end), ...
'pi_vec', [sum(params0.pi_vec([1, 3])), sum(params0.pi_vec([2, 3]))]));
mapparams = @(x)mapparams_generic(x, params);

fitfunc = @(x0)mapparams(fminsearch(@(x)BGMG_util.BGMG_fminsearch_cost(mapparams(x)), mapparams(x0), fminsearch_options));
Expand Down

0 comments on commit abfa1d3

Please sign in to comment.