The quick answer:
With the formula given as $kTB$, $kT$ is a One-Sided Noise Density and therefore $B=f_s/2$ assuming we are interested in the full bandwidth from DC to Nyquist, assuming 1/f noise and phase noise is not a factor and assuming the system has been perfectly filtered with a brick-wall low pass filter prior to sampling with bandwidth $f_s/2$. None of these are realistic but I'll walk through the details below to establish reasonable operating ranges to use.
To add this to a sinusoidal time domain signal, create the additive white Gaussian noise process using the randn
function with the standard deviation consistent with the noise power needed ($kTB$ is the total noise power as the variance $\sigma^2$, so the standard deviation would be given as $\sqrt{kT}$, so the noise samples can be generated using k*T*randn(nsamps)
where nsamps
is the total number of samples used in the simulation.
The details we shouldn't skip:
As I'll detail, this question involves a lot of clarifications as to if we are representing a real passband or complex baseband signal, how much of the bandwidth of the digitized signal is our "bandwidth of interest" and the considerations of realizable filtering for a signal representing digitized samples of a continuous time signal. I'll clarify these points as I proceed with the explanations below starting with a clearer picture of a continuous time real passband signal, the difference between one-sided and two-sided noise densities, and what occurs when we sample that.
$kTB$ is the total power due to thermal noise (Johnson noise) as a white noise process and represents the noise contribution within a bandwidth of interest $B$ at a given temperature $T$ to a real signal at some higher passband frequency (as low pass signals can also be significantly affected by other noise sources such as 1/f noise as we approach DC). This noise is a white Gaussian distributed process and the one-sided noise density is given as $N_o = kT$ with units of W/Hz (and is approximately -174 dBm/Hz at room temperature). Multiplying by $B$ results in the total power over a bandwidth of interest. We also typically will have additional elevations in the noise floor due to active electronics known as "Noise Figure". The OP has assumed the noise figure is zero so I won't go into further details of that here. The two sided noise density would in contrast be $N_o/2 = kT/2$. What do I mean by "one-sided" vs "two-sided"? I'll cover that and other relevant details through the example that is developed below.
Consider first the case of a real pure continuous-time sinusoid given as $A\cos(2\pi f_o t)$ in the presence of thermal noise. One possible depiction of the power spectral density (PSD) is shown below as a "One-Sided PSD". The PSD shows frequency on the horizontal axis in Hz and the density on the vertical axis in W/Hz (typically plotted in dB such as dBm/Hz or dBW/Hz etc). Frequency in this case is only represented as a positive quantity, and in this case specifically the noise density due to thermal noise would be $N_o=kT$. I am also showing importantly how as we approach DC we will also begin to be dominated by $1/f$ noise which is not a "white noise" process and manifests in longer duration signal captures being non-stationary. I have shown the power due to the pure sinusoid as an impulse with total power given as $A^2/2$ (assuming a resistance normalized to $R=1$ ohm if the units of power is Watts with units for $A$ as Volts). Note that any realizable sinusoid will also have non-white noise as we approach it referred to as "phase noise" but for this explanation I will assume a pure tone.
Next I will bring in the consideration of bandwidth $B$. Below shows the concept of selecting a particular frequency range of interest with the range given as $B$ Hz. Since $N_o$ is a noise density in Watts/Hz, the total noise power will be the integrated power over this frequency range. Given the noise is flat (white), this resulting total power will be $N_oB = kTB$ Watts.
How is $B$ chosen in this case? Observation time or total duration of the signal is a significant factor in choosing the lower frequency limit. Consider how we can never actually observe "DC" (we would need to watch forever!). The observation time over duration $T$ seconds is reasonably approximated as a first order high-pass response with cutoff given as $1/T$ Hz. The upper limit would be given by any filtering in our system or the measurement system used. All physical systems will have a finite bandwidth, and ultimately in this case we are making a measurement of power (or perhaps signal to noise ratio, SNR, and with that making some estimate as to the level or features of a signal). It is very significant that we understand what that bandwidth is, in order to accurately predict the total power due to the thermal noise contribution.
With that clarified I will now bring in the concept of a "Two-Sided PSD". The same signal above as a sinusoid given as $A\cos(2\pi f_o t)$ in the presence of thermal noise with zero noise figure, as well as 1/f noise as we approach DC, can be represented with a two-sided PSD as depicted in the graphic below:
In this case the horizontal frequency axis has a sign as positive and negative frequencies, which means each point on the frequency axis does not represent the power of a sinusoidal component but instead represents the power of an exponential component. The simplest explanation I have for this is to review the relationship of exponential versus sinusoidal frequencies as given by Euler's formula:
$$A\cos(2\pi f_o t) = \frac{A}{2}e^{j2\pi f_o t} + \frac{A}{2}e^{-j2\pi f_o t}$$
From that we see how a cosine with peak magnitude of $A$ is represented by two constant magnitude exponentials each with magnitude $A/2$. $e^{j2\pi f_o t}$ is a positive frequency component and $e^{-j2\pi f_ot}$ is a negative frequency component. The power of each is the magnitude squared resulting in the $A^2/4$ values we see in the graphic above for each of these two frequency components. We note from this that the total power in the sine wave, given as $A^2/2$ has been split into two for the two-sided PSD as two components each at $A^2/4$. Similarly the power spectral density due to thermal noise will also be divided in half since every unit of bandwidth now represents frequency ranges that are both in the positive and negative frequency axis.
For example and clarity, if our sinusoid was $10\cos(2\pi f_o t)$ with $f_o= 1$ MHz, and $B$ was 200 KHz centered on $f_o$, for the one-sided case we would have a single impulse at 1 MHz with total power $A^2/2 = 50$ W. $B$ would extend from $0.9$ MHz to $1.1$ MHz with a total noise power of $-174$ dBm/Hz + $10\log_{10}(200e3) \approx -121$ dBm. For the two-sided case we would have two impulses each at $\pm 1$ MHz and each with a total power $A^2/4= 25$ W. $B$ would extend from $+0.9$ MHz to $1.1$ MHz, and from $-0.9$ MHz to $-1.1$ MHz. The total noise power in each of these two frequency bands would be $-177$ dBm/Hz + $10\log_{10}(200e3) \approx -124$ dBm. The total signal power is the sum of the two as $50W$ and the total noise power would similarly be 3 dB higher as $-121$ dBm, so the resulting signal and noise is the same and it is just a matter of being careful in its representation and not over-counting. My point of including the 1/f noise (or pointing it out) in both cases is that we always need to be very careful of this, and check that for purposes of assuming a white noise floor that 1/f noise is not yet becoming significant (ultimately this is a question of how stationary our signal is; as we increase the measurement duration the effects of 1/f noise will become dominant and effect our overall noise measurements unless we high-pass filter specifically to avoid it, which will also reduce our bandwidth $B$ accordingly; these are all important considerations).
With that understood we can now bring in the considerations of having this waveform sampled. The sampled spectrum has a unique frequency span referred to as the "Nyquist Zone" with the first Nyquist Zone extending either from DC to $f_s/2$ if we use a one-sided spectrum OR from $-f_s/2$ to $+f_s/2$ if we use a two-sided spectrum, as depicted in the graphic below:
Assuming (importantly!) that the continuous time system that these samples represent has been properly anti-alias filtered (meaning all energy above $|f_s/2|$ has been filtered out) prior to sampling, then the noise densities for each case would be given as follows, following the same explanation for the continuous time case above. $B$ as described can't extend all the way to DC for it's lower end, and the anti-alias filter as implemented cannot represent a brick-wall response, so $B$ also can't extend all the way to $|f_s/2|$ for it's upper end. Therefore in practical application the usable bandwidth that would be $B< f_s/2$ and would need to be specified specific to the application. (Further the noise $N_o$ would likely be amplified prior to sampling to be above the realizable quantization noise floor, which we wouldn't want to be the limiting contribution to our overall noise).
Hopefully this has clarified the considerations toward practical application within the constraints of what can be reasonably included in a short Q&A forum. Please see this answer which goes into further details about considerations related including the concept of passband vs baseband signals: https://dsp.stackexchange.com/a/86986/21048