1function sample = rap_sample(RAP, n, xs)
2% SAMPLE = RAP_SAMPLE(RAP, N, XS) - Generate random samples from RAP distribution
4% Generate samples from a Rational Arrival Process (RAP) distribution.
5% The marginal distribution of RAP inter-arrival times
is a Matrix
6% Exponential (ME) distribution, so
this function delegates to me_sample.
9% RAP: RAP distribution as either:
11% - Process cell array {H0, H1}
12% N: Number of samples to generate (
default: 1)
13% XS: Optional pre-computed grid for CDF evaluation
14% If not provided, auto-generates grid based on mean and variance
17% SAMPLE: Column vector of N samples from the RAP marginal distribution
20% This function generates samples from the marginal distribution only.
21% It does not preserve the correlation structure of the RAP.
22% For full RAP simulation with correlations, use map_sample instead.
25% rap = RAP([-2, 1; 0.5, -1.5], [0.5, 0.5; 0.5, 0.5]);
26% samples = rap_sample(rap, 10000);
28% % Or use process representation directly
29% RAP_proc = {[-2, 1; 0.5, -1.5], [0.5, 0.5; 0.5, 0.5]};
30% samples = rap_sample(RAP_proc, 10000);
32% Copyright (c) 2012-2026, Imperial College London
35% Handle input arguments
40% Extract process representation
42 RAP_proc = RAP.getProcess();
46 error('RAP must be either a RAP
object or a cell array {H0, H1}
');
49% Delegate to me_sample
50% The marginal distribution of RAP is ME with the same {H0, H1} representation
51if nargin < 3 || isempty(xs)
52 sample = me_sample(RAP_proc, n);
54 sample = me_sample(RAP_proc, n, xs);