fcalc_tail_yp

PURPOSE ^

SYNOPSIS ^

function [fx,normfx] = fcalc_tail_yp(args_in,x_range,x,testmode)

DESCRIPTION ^

 Function for script randreject_yp. Calculate the launched n||0 power
 spectrum for the LH wave. Need output of calc_tail_jd.m 

 Input:

   - args_in : input arguments of fcalc_tail_yp 
   - x_range : range of the random variable [3,1] or [1,3] for example. If [1,3], f(1)/f(3) = 1/h, and if [3,1], f(1)/f(3) = h.

 Output:

   - fx : p.d.f. of the random variable x [N,1]
   - normfx :  numerical norm of the p.d.f fx [1,1]

 by Y.Peysson (CEA-IRFM) <yves.peysson@cea.fr> and J. Decker (CEA-IRFM) <joan.decker@cea.fr>

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [fx,normfx] = fcalc_tail_yp(args_in,x_range,x,testmode)
0002 %
0003 % Function for script randreject_yp. Calculate the launched n||0 power
0004 % spectrum for the LH wave. Need output of calc_tail_jd.m
0005 %
0006 % Input:
0007 %
0008 %   - args_in : input arguments of fcalc_tail_yp
0009 %   - x_range : range of the random variable [3,1] or [1,3] for example. If [1,3], f(1)/f(3) = 1/h, and if [3,1], f(1)/f(3) = h.
0010 %
0011 % Output:
0012 %
0013 %   - fx : p.d.f. of the random variable x [N,1]
0014 %   - normfx :  numerical norm of the p.d.f fx [1,1]
0015 %
0016 % by Y.Peysson (CEA-IRFM) <yves.peysson@cea.fr> and J. Decker (CEA-IRFM) <joan.decker@cea.fr>
0017 %
0018 if nargin < 3,
0019     error('Wrong number of input arguments in fcalc_tail_yp.m');
0020 end
0021 %
0022 Npar0_tail = args_in{1};
0023 dNpar0_tail = args_in{2};
0024 P0_2piRp_tail = args_in{3};
0025 P0_2piRp = args_in{4};
0026 %
0027 n_tail = length(Npar0_tail);
0028 %
0029 for in = 1:n_tail,
0030     xdPdN(in,:) = P0_2piRp_tail(in)/P0_2piRp*exp(-(x - Npar0_tail(in)).^2/dNpar0_tail(in).^2)/(sqrt(pi)*dNpar0_tail(in));
0031 end
0032 %
0033 fx = sum(xdPdN);fx = fx(:);
0034 %
0035 % Test that fx is normalized to one in the interval defined by x_range
0036 %
0037 if nargin > 3,
0038     if testmode,
0039         x_test = linspace(x_range(1),x_range(2),10000);
0040         %
0041         for in = 1:n_tail,
0042             xdPdN_test(in,:) = P0_2piRp_tail(in)/P0_2piRp*exp(-(x_test - Npar0_tail(in)).^2/dNpar0_tail(in).^2)/(sqrt(pi)*dNpar0_tail(in));
0043         end
0044         %
0045         fx_test = sum(xdPdN_test);
0046         %
0047         normfx = trapz(x_test,fx_test);
0048     end
0049 else
0050     normfx = NaN;
0051 end

Community support and wiki are available on Redmine. Last update: 18-Apr-2019.