Normal distribution & Hypothesis testing queries Is Z-test or t-test only carried out to make inferences about the population?
Is is true that t-test is preferred over Z-test when the sample size is >= 30?
For prediction we don't require any of these tests, right? If we do, is there any pre-requisite that we need to carry out before prediction is done so that we can minimize the error and improve the accuracy of the model?
Earlier thought that the data has to be normally distributed, before prediction is carried out (where we probably go for Z-test), then is it that t-test is used only for hypothesis testing?
 A: Here is a summary of facts that should answer your questions. I suppose you can find discussions of them in your textbook or online, but it may be
useful to see them all stated together in the same place.
z test and CI. For data $X_1. X_2, \dots, X_n$ randomly sampled from 
$\mathsf{Norm}(\mu, \sigma),$ where $\sigma$ is known, a
z-test is used to test $H_0: \mu = \mu_0$ against $H_a: \mu \ne \mu_0.$
The test statistic is $Z = \frac{\bar X - \mu_0}{\sigma/\sqrt{n}},$ where
$\bar X$ is the sample mean of the $X_i.$
The null hypothesis $H_0$ is rejected at the 5% level of significance
if $|Z| > 1.96.$ (The number $z^* = 1.96$ cuts probability $0.025$ from
the upper tail of $\mathsf{Norm}(0,1).$
If the goal is to estimate the unknown population mean $\mu,$ then $\bar X$ is the point estimate of $\mu$ and a 95% confidence for $\mu$ is of the
form $\bar X \pm 1.96\frac{\sigma}{\sqrt{n}}.$
Note: One-sided tests such as $H_0: \mu = \mu_0$ against
$H_a: \mu > \mu_0$ are tested using the normal distribution, in similar
ways. Also, one-sided CIs (providing only a lower or upper bound on $\mu)$ are also available.
t test and CI. For data $X_1. X_2, \dots, X_n$ randomly sampled from 
$\mathsf{Norm}(\mu, \sigma),$ where $\sigma$ is unknown, a
t-test is used to test $H_0: \mu = \mu_0$ against $H_a: \mu \ne \mu_0.$
The test statistic is $T = \frac{\bar X - \mu_0}{S/\sqrt{n}},$ where
$\bar X$ is the sample mean of the $X_i$ and the sample standard deviation $S$ estimates $\sigma.$
The null hypothesis $H_0$ is rejected at the 5% level of significance
if $|T| > t^*.$ (The number $t^*$ cuts probability $0.025$ from
the upper tail of $\mathsf{T}(\nu=n-1),$ Student's t distribution with $n-1$ degrees of freedom.
If the goal is to estimate the unknown population mean $\mu,$ then $\bar X$ is the point estimate of $\mu$ and a 95% confidence for $\mu$ is of the
form $\bar X \pm t^*\frac{S}{\sqrt{n}}.$
Note: One-sided tests such as $H_0: \mu = \mu_0$ against
$H_a: \mu > \mu_0$ are tested using Student's t distributions, in similar
ways. Also, one-sided CIs (providing only a lower or upper bound on $\mu)$ are also available.
A 95% confidence interval for $\sigma^2$ is of the form 
$\left(\frac{(n-1)S^2}{U}, \frac{(n-1)S^2}{L}\right),$ where numbers $L$ and $U$ cut probability 0.025 from the lower and upper tails, respectively of
$\mathsf{Chisq}(\nu=n-1),$ the chi-squared distribution with $n-1$ degrees of freedom. A 95% CI for $\sigma$ is found by taking square
roots of the endpoints of the CI for $\sigma^2.$
Distinction between z and t procedures. Strictly speaking, whether or not $n \ge 30$ has no role in deciding
whether to use z or t procedures. The correct distinction is to use
z procedures when $\sigma$ is known and t procedures when $\sigma$ is
unknown and estimated by $S.$  However, for tests at the 5% level of
significance and for 95% CIs only, z procedures are approximately
correct when $n \ge 30$ because then $t^* \approx 1.96.$ [For example, when $n = 35,$ one has $t^* = 2.0322.]$
