code: def frequency_noise_from_psd(psd, seed=None):
      
      sigma = 0.5 * (psd / psd.delta_f) ** (0.5)
      if seed is not None:
          numpy.random.seed(seed)
      sigma = sigma.numpy()
      dtype = complex_same_precision_as(psd)
  
      not_zero = (sigma != 0)
  
      sigma_red = sigma[not_zero]
      noise_re = numpy.random.normal(0, sigma_red)
      noise_co = numpy.random.normal(0, sigma_red)
      noise_red = noise_re + 1j * noise_co
  
      noise = numpy.zeros(len(sigma), dtype=dtype)
      noise[not_zero] = noise_red
  
      return FrequencySeries(noise,
                             delta_f=psd.delta_f,
                             dtype=dtype)
docs: Create noise with a given psd.
  
      Return noise coloured with the given psd. The returned noise
      FrequencySeries has the same length and frequency step as the given psd.
      Note that if unique noise is desired a unique seed should be provided.
  
      Parameters
      ----------
      psd : FrequencySeries
          The noise weighting to color the noise.
      seed : {0, int} or None
          The seed to generate the noise. If None specified,
          the seed will not be reset.
  
      Returns
      --------
      noise : FrequencySeriesSeries
          A FrequencySeries containing gaussian noise colored by the given psd.