# How can I verify that my solution is correct when finding the PDF and CDF of a random process?

If I have $$X(t) = \sin(\omega t + \theta)$$ where $$\omega$$ is constant and $$\theta$$ ~ $$U[0,2\pi]$$, and I need to find the PDF and CDF of $$X(t)$$, then how can I confirm my solutions for the PDF and CDF are valid?

Apart from the usual mathematical techniques of checking your derivation, checking for consistency (e.g., differentiating the CDF to see whether it equals the PDF), and considering whether your answer makes sense, whenever there is a question of determining the distribution of a random variable (or collection of variables) you almost always have available the option of simulation.

In many cases this is a mechanical, nearly mindless exercise -- and it is carried out using such different reasoning processes (it's a programming exercise rather than a mathematical one) that it serves as an excellent check.

For this purpose it's a good idea not to be clever or efficient about the simulation: make the code reflect the information you have as closely as possible. In the example below, the process $$X$$ is computed as

X <- outer(theta, times, function(theta, t) sin(omega*t + theta))


That's simple to code and easy to compare to your formula. The rest of the code is just pre- and post-processing.

You can find thousands of worked examples here on Cross Validated: search for names of common uniform random number generators, such as runif and rnorm, made popular on the R platform.

As an example, below is R code to simulate your process for eight randomly-chosen times $$t$$ and display histograms of the simulated values. Over those histograms are plotted the graphs of the PDF I think is the solution. You can see these graphs agree closely with the histograms, thereby bolstering the likelihood I am right. (You can perform a distributional goodness of fit test of each graph for a more rigorous check, but that's a matter for a separate thread.) If you wish to check the CDF, plot the empirical cumulative distribution functions (available through the ecdf function in R) and overplot those with your CDF to compare. See, inter alia, https://stats.stackexchange.com/a/471775/919, https://stats.stackexchange.com/a/472768/919, or https://stats.stackexchange.com/a/464101/919 for examples. The code is below. Because you are not asking for the answer, I have omitted the body of the PDF function f. Nevertheless, this figure already reveals a lot: the distribution of $$X(t)$$ does not vary with $$t.$$

#
# Specify the process by initializing its parameters.
#
omega <- 4/3
#
# Select a set of "times" at which to sample it.
#
times <- sort(runif(8, 0, 2*pi/omega))
#
# Sample the process n times, storing each independent sample in a row of X.
#
n <- 1e5
theta <- runif(n, 0, 2*pi)
X <- outer(theta, times, function(theta, t) sin(omega*t + theta))
#
# Plot histograms of each X(t).
#
h <- function(x, t) {
hist(x, xlim=c(-1,1), freq=FALSE, breaks=50, col="#f8f8f8", border="#505050",
xlab=expression(X[t]), cex.lab=1.25,
main=paste0("t=",signif(t,3)), cex.main=1)
f <- function(x) # (Body omitted.)