python类iscomplexobj()的实例源码

pyfftw_fft.py 文件源码 项目:mpiFFT4py 作者: spectralDNS 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def dct(a, b, type=2, axis=0, overwrite_input=False, threads=1, planner_effort="FFTW_EXHAUSTIVE"):
        global dct_object
        key = (a.shape, a.dtype, overwrite_input, axis, type)
        if not key in dct_object:
            if iscomplexobj(a):
                ac = a.real.copy()
            else:
                ac = a
            dct_object[key] = pyfftw.builders.dct(ac, axis=axis, type=type, 
                                                  overwrite_input=overwrite_input, 
                                                  threads=threads,
                                                  planner_effort=planner_effort)

        dobj = dct_object[key]
        c = dobj.get_output_array()
        if iscomplexobj(a):
            dobj(a.real, c)
            b.real[:] = c
            dobj(a.imag, c)
            b.imag[:] = c

        else:
            dobj(a)
            b[:] = c
        return b
aggregate_numpy.py 文件源码 项目:mobula 作者: wkcn 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
def _sort(group_idx, a, size, fill_value, dtype=None, reversed_=False):
    if np.iscomplexobj(a):
        raise NotImplementedError("a must be real, could use np.lexsort or "
                                  "sort with recarray for complex.")
    if not (np.isscalar(fill_value) or len(fill_value) == 0):
        raise ValueError("fill_value must be scalar or an empty sequence")
    if reversed_:
        order_group_idx = np.argsort(group_idx + -1j * a, kind='mergesort')
    else:
        order_group_idx = np.argsort(group_idx + 1j * a, kind='mergesort')
    counts = np.bincount(group_idx, minlength=size)
    if np.ndim(a) == 0:
        a = np.full(size, a, dtype=type(a))
    ret = np.split(a[order_group_idx], np.cumsum(counts)[:-1])
    ret = np.asarray(ret, dtype=object)
    if np.isscalar(fill_value):
        fill_untouched(group_idx, ret, fill_value)
    return ret
aggregate_numpy.py 文件源码 项目:mobula 作者: wkcn 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def _sum(group_idx, a, size, fill_value, dtype=None):
    dtype = minimum_dtype_scalar(fill_value, dtype, a)

    if np.ndim(a) == 0:
        ret = np.bincount(group_idx, minlength=size).astype(dtype)
        if a != 1:
            ret *= a
    else:
        if np.iscomplexobj(a):
            ret = np.empty(size, dtype=dtype)
            ret.real = np.bincount(group_idx, weights=a.real,
                              minlength=size)
            ret.imag = np.bincount(group_idx, weights=a.imag,
                              minlength=size)
        else:
            ret = np.bincount(group_idx, weights=a,
                              minlength=size).astype(dtype)

    if fill_value != 0:
        fill_untouched(group_idx, ret, fill_value)
    return ret
aggregate_numpy.py 文件源码 项目:mobula 作者: wkcn 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def _mean(group_idx, a, size, fill_value, dtype=np.dtype(np.float64)):
    if np.ndim(a) == 0:
        raise ValueError("cannot take mean with scalar a")
    counts = np.bincount(group_idx, minlength=size)
    if np.iscomplexobj(a):
        dtype = a.dtype  # TODO: this is a bit clumsy
        sums = np.empty(size, dtype=dtype)
        sums.real = np.bincount(group_idx, weights=a.real,
                                minlength=size)
        sums.imag = np.bincount(group_idx, weights=a.imag,
                                minlength=size)
    else:
        sums = np.bincount(group_idx, weights=a,
                           minlength=size).astype(dtype)

    with np.errstate(divide='ignore'):
        ret = sums.astype(dtype) / counts
    if not np.isnan(fill_value):
        ret[counts == 0] = fill_value
    return ret
signal_models.py 文件源码 项目:parametrix 作者: vincentchoqueuse 项目源码 文件源码 阅读 37 收藏 0 点赞 0 评论 0
def score(self,Y,type="loglikelihood",method="BIC"):

        if type=="loglikelihood":
            score=log_likelihood=self.compute_loglikelihood(Y)

        if type=="penalized_loglikelihood":
            N=np.prod(Y.shape)
            if np.iscomplexobj(Y)==True:
                N=N*2
            log_likelihood=self.compute_loglikelihood(Y)
            nb_free_parameters=self.get_nb_free_parameters()
            penalty_term=penalty_term_IC(nb_free_parameters,N,method=method)
            score=-2*log_likelihood+penalty_term
        return score

    ## method for plotting
test_polynomial.py 文件源码 项目:deliver 作者: orchestor 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def test_poly(self):
        assert_array_almost_equal(np.poly([3, -np.sqrt(2), np.sqrt(2)]),
                                  [1, -3, -2, 6])

        # From matlab docs
        A = [[1, 2, 3], [4, 5, 6], [7, 8, 0]]
        assert_array_almost_equal(np.poly(A), [1, -6, -72, -27])

        # Should produce real output for perfect conjugates
        assert_(np.isrealobj(np.poly([+1.082j, +2.613j, -2.613j, -1.082j])))
        assert_(np.isrealobj(np.poly([0+1j, -0+-1j, 1+2j,
                                      1-2j, 1.+3.5j, 1-3.5j])))
        assert_(np.isrealobj(np.poly([1j, -1j, 1+2j, 1-2j, 1+3j, 1-3.j])))
        assert_(np.isrealobj(np.poly([1j, -1j, 1+2j, 1-2j])))
        assert_(np.isrealobj(np.poly([1j, -1j, 2j, -2j])))
        assert_(np.isrealobj(np.poly([1j, -1j])))
        assert_(np.isrealobj(np.poly([1, -1])))

        assert_(np.iscomplexobj(np.poly([1j, -1.0000001j])))

        np.random.seed(42)
        a = np.random.randn(100) + 1j*np.random.randn(100)
        assert_(np.isrealobj(np.poly(np.concatenate((a, np.conjugate(a))))))
arpack.py 文件源码 项目:Parallel-SGD 作者: angadgill 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def _augmented_orthonormal_cols(x, k):
    # extract the shape of the x array
    n, m = x.shape
    # create the expanded array and copy x into it
    y = np.empty((n, m+k), dtype=x.dtype)
    y[:, :m] = x
    # do some modified gram schmidt to add k random orthonormal vectors
    for i in range(k):
        # sample a random initial vector
        v = np.random.randn(n)
        if np.iscomplexobj(x):
            v = v + 1j*np.random.randn(n)
        # subtract projections onto the existing unit length vectors
        for j in range(m+i):
            u = y[:, j]
            v -= (np.dot(v, u.conj()) / np.dot(u, u.conj())) * u
        # normalize v
        v /= np.sqrt(np.dot(v, v.conj()))
        # add v into the output array
        y[:, m+i] = v
    # return the expanded array
    return y
numpy_fft.py 文件源码 项目:mpiFFT4py 作者: spectralDNS 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def dct(a, b, type=2, axis=0, **kw):
    if iscomplexobj(a):
        b.real[:] = dct1(a.real, type=type, axis=axis)
        b.imag[:] = dct1(a.imag, type=type, axis=axis)
        return b

    else:
        b[:] = dct1(a, type=type, axis=axis)
        return b

# Define functions taking both input array and output array
raputil.py 文件源码 项目:onsager_deep_learning 作者: mborgerding 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def rms(x,axis=None):
    'calculate the root-mean-square of a signal, if axis!=None, then reduction will only be along the given axis/axes'
    if np.iscomplexobj(x):
        x=abs(x)
    return np.sqrt(np.mean(np.square(x),axis) )
raputil.py 文件源码 项目:onsager_deep_learning 作者: mborgerding 项目源码 文件源码 阅读 41 收藏 0 点赞 0 评论 0
def fwd(self,X):
        'forward linear operator'
        assert np.iscomplexobj(X) == self.cpx,'wrong value for cpx in constructor'
        return np.einsum('...jk,mj->...mk',X,self.S)
raputil.py 文件源码 项目:onsager_deep_learning 作者: mborgerding 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def adj(self,X):
        'adjoint linear operator'
        assert np.iscomplexobj(Y) == self.cpx,'wrong value for cpx in constructor'
        return np.einsum('...jk,mj->...mk',X,self.S.T.conj())
raputil.py 文件源码 项目:onsager_deep_learning 作者: mborgerding 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
def _test_awgn(self,cpx):
            snr = np.random.uniform(3,20)
            p = Problem(cpx=cpx,SNR_dB=snr)
            X = p.genX(5)
            self.assertEqual( np.iscomplexobj(X) , cpx )
            Y0 = p.fwd(X)
            self.assertEqual( np.iscomplexobj(Y0) , cpx )
            Y,wvar = p.add_noise(Y0)
            self.assertEqual( np.iscomplexobj(Y) , cpx )
            snr_obs = -20*np.log10( la.norm(Y-Y0)/la.norm(Y0))
            self.assertTrue( abs(snr-snr_obs) < 1.0, 'gross error in add_noise')
            wvar_obs = la.norm(Y0-Y)**2/Y.size
            self.assertTrue( .5 < wvar_obs/wvar < 1.5, 'gross error in add_noise wvar')
core.py 文件源码 项目:radar 作者: amoose136 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def var(self, axis=None, dtype=None, out=None, ddof=0):
        ""
        # Easy case: nomask, business as usual
        if self._mask is nomask:
            return self._data.var(axis=axis, dtype=dtype, out=out, ddof=ddof)
        # Some data are masked, yay!
        cnt = self.count(axis=axis) - ddof
        danom = self.anom(axis=axis, dtype=dtype)
        if iscomplexobj(self):
            danom = umath.absolute(danom) ** 2
        else:
            danom *= danom
        dvar = divide(danom.sum(axis), cnt).view(type(self))
        # Apply the mask if it's not a scalar
        if dvar.ndim:
            dvar._mask = mask_or(self._mask.all(axis), (cnt <= 0))
            dvar._update_from(self)
        elif getattr(dvar, '_mask', False):
            # Make sure that masked is returned when the scalar is masked.
            dvar = masked
            if out is not None:
                if isinstance(out, MaskedArray):
                    out.flat = 0
                    out.__setmask__(True)
                elif out.dtype.kind in 'biu':
                    errmsg = "Masked data information would be lost in one or "\
                             "more location."
                    raise MaskError(errmsg)
                else:
                    out.flat = np.nan
                return out
        # In case with have an explicit output
        if out is not None:
            # Set the data
            out.flat = dvar
            # Set the mask if needed
            if isinstance(out, MaskedArray):
                out.__setmask__(dvar.mask)
            return out
        return dvar
transform.py 文件源码 项目:pisap 作者: neurospin 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def analysis(self, **kwargs):
        """ Decompose a real or complex signal using ISAP.

        Fill the instance 'analysis_data' and 'analysis_header' parameters.

        Parameters
        ----------
        kwargs: dict (optional)
            the parameters that will be passed to
            'pisap.extensions.mr_tansform'.
        """
        # Checks
        if self._data is None:
            raise ValueError("Please specify first the input data.")

        # Update ISAP parameters
        kwargs["type_of_multiresolution_transform"] = self.isap_transform_id
        kwargs["number_of_scales"] = self.nb_scale

        # Analysis
        if numpy.iscomplexobj(self._data):
            analysis_data_real, self.analysis_header = self._analysis(
                self._data.real, **kwargs)
            analysis_data_imag, _ = self._analysis(
                self._data.imag, **kwargs)
            if isinstance(analysis_data_real, numpy.ndarray):
                self._analysis_data = (
                    analysis_data_real + 1.j * analysis_data_imag)
            else:
                self._analysis_data = [
                    re + 1.j * ima
                    for re, ima in zip(analysis_data_real, analysis_data_imag)]
        else:
            self._analysis_data, self._analysis_header = self._analysis(
                self._data, **kwargs)
_analogsignalarray.py 文件源码 项目:nelpy 作者: nelpy 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
def iscomplex(self):
        """Returns True if any part of the signal is complex."""
        return np.any(np.iscomplex(self._ydata))
        # return np.iscomplexobj(self._ydata)
core.py 文件源码 项目:krpcScripts 作者: jwvanderbeck 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def var(self, axis=None, dtype=None, out=None, ddof=0):
        ""
        # Easy case: nomask, business as usual
        if self._mask is nomask:
            return self._data.var(axis=axis, dtype=dtype, out=out, ddof=ddof)
        # Some data are masked, yay!
        cnt = self.count(axis=axis) - ddof
        danom = self.anom(axis=axis, dtype=dtype)
        if iscomplexobj(self):
            danom = umath.absolute(danom) ** 2
        else:
            danom *= danom
        dvar = divide(danom.sum(axis), cnt).view(type(self))
        # Apply the mask if it's not a scalar
        if dvar.ndim:
            dvar._mask = mask_or(self._mask.all(axis), (cnt <= 0))
            dvar._update_from(self)
        elif getattr(dvar, '_mask', False):
            # Make sure that masked is returned when the scalar is masked.
            dvar = masked
            if out is not None:
                if isinstance(out, MaskedArray):
                    out.flat = 0
                    out.__setmask__(True)
                elif out.dtype.kind in 'biu':
                    errmsg = "Masked data information would be lost in one or "\
                             "more location."
                    raise MaskError(errmsg)
                else:
                    out.flat = np.nan
                return out
        # In case with have an explicit output
        if out is not None:
            # Set the data
            out.flat = dvar
            # Set the mask if needed
            if isinstance(out, MaskedArray):
                out.__setmask__(dvar.mask)
            return out
        return dvar
dialog_SVD.py 文件源码 项目:CRIkit2 作者: CoherentRamanNIST 项目源码 文件源码 阅读 48 收藏 0 点赞 0 评论 0
def __init__(self, data, img_shape, mask=None, use_imag=True, img_all=None, spect_all=None,
                 parent=None):
        super(DialogSVD, self).__init__(parent=parent) ### EDIT ###
        self.setup(parent=parent)
        self.setupData(img_shape=img_shape)
        self.ui_changes()

        self.U = data[0]
        self.s = data[1]
        self.Vh = data[2]
        self._n_factors = self.s.size

        self.mask = mask

        self._use_imag = use_imag # By default, use imag portion of complex data

        if (img_all is None) and (spect_all is None):
            cube_all = self.combiner(selections=_np.arange(self._n_factors))
            self.img_all = self.mean_spatial(cube_all)
            self.spect_all = self.mean_spectral(cube_all)
        else:
            self.img_all = img_all.real
            if _np.iscomplexobj(spect_all):
                if self._use_imag:    
                    self.spect_all = spect_all.imag
                else:
                    self.spect_all = spect_all.real
            else: 
                self.spect_all = spect_all

        self.updatePlots(0)
        self.updateCurrentRemainder()
dialog_SVD.py 文件源码 项目:CRIkit2 作者: CoherentRamanNIST 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def mean_spatial(self, cube):
        ret = cube.mean(axis=-1)
        ret = ret.reshape((self._n_y, self._n_x))
        if _np.iscomplexobj(ret):
            if self._use_imag:
                return _np.imag(ret)
            else:
                return _np.real(ret)
        else:
            return ret
dialog_SVD.py 文件源码 项目:CRIkit2 作者: CoherentRamanNIST 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def mean_spectral(self, cube):
        ret = cube.mean(axis=0)

        if _np.iscomplexobj(ret):
            if self._use_imag:
                return _np.imag(ret)
            else:
                return _np.real(ret)
        else:
            return ret
dialog_SVD.py 文件源码 项目:CRIkit2 作者: CoherentRamanNIST 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def get_spatial_slice(self, num):
        img = self.U[...,num].reshape((self._n_y, self._n_x))
        return _np.real(img)

        # Used to return complex, but the SVD of complex numbers tends to
        # shove everything in U into the real component

        # if _np.iscomplexobj(img):
        #     if self._use_imag:
        #         return _np.imag(img)
        #     else:
        #         return _np.real(img)
        # else:
        #     return img
dialog_SVD.py 文件源码 项目:CRIkit2 作者: CoherentRamanNIST 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def get_spectral_slice(self, num):
        spect = self.Vh[num,:]

        if _np.iscomplexobj(spect):
            if self._use_imag:
                return _np.imag(spect)
            else:
                return _np.real(spect)
        else:
            return spect
CRIkitUI.py 文件源码 项目:CRIkit2 作者: CoherentRamanNIST 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def errorCorrectScale(self):
        """
        Error Correction: Scale
        """
        rand_spectra = self.hsi.get_rand_spectra(5, pt_sz=3, quads=True,
                                                 full=False)
        if _np.iscomplexobj(rand_spectra):
            rand_spectra = rand_spectra.real

        rng = self.hsi.freq.op_range_pix

        plugin = _widgetSG(window_length=601, polyorder=2)
        winPlotEffect = _DialogPlotEffect.dialogPlotEffect(rand_spectra,
                                                           x=self.hsi.f,
                                                           plugin=plugin,
                                                           parent=self)
        if winPlotEffect is not None:
            win_size = winPlotEffect.parameters['window_length']
            order = winPlotEffect.parameters['polyorder']

            scale_err_correct_sg = _ScaleErrCorrectSG(win_size=win_size,
                                                      order=order,
                                                      rng=rng)
            scale_err_correct_sg.transform(self.hsi.data)

            # Backup for Undo
            self.bcpre.add_step(['ScaleErrorCorrectSG',
                                 'win_size', win_size,
                                 'order', order])

            if self.ui.actionUndo_Backup_Enabled.isChecked():
                try:
                    _BCPre.backup_pickle(self.hsi, self.bcpre.id_list[-1])
                except:
                    print('Error in pickle backup (Undo functionality)')
                else:
                    self.bcpre.backed_up()
        self.changeSlider()
spectrum.py 文件源码 项目:CRIkit2 作者: CoherentRamanNIST 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
def data_imag_over_real(self):
        if _np.iscomplexobj(self._data):
            if isinstance(self._data, _np.ndarray):
                return self._data.imag
            else:
                return _np.imag(self._data)
        else:
            return self._data
spectrum.py 文件源码 项目:CRIkit2 作者: CoherentRamanNIST 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def data_real_over_imag(self):
        if _np.iscomplexobj(self._data):
            if isinstance(self._data, _np.ndarray):
                return self._data.real
            else:
                return _np.real(self._data)
        else:
            return self._data
subtract_baseline.py 文件源码 项目:CRIkit2 作者: CoherentRamanNIST 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def _calc(self, data, ret_obj, **kwargs):

        self._inst_als = _AlsCvxopt(**kwargs)

        try:
            # Get the subarray shape
            shp = data.shape[0:-2]
            total_num = _np.array(shp).prod()

            # Iterate over the sub-array -- super slick way of doing it
            for num, idx in enumerate(_np.ndindex(shp)):
                print('Detrended iteration {} / {}'.format(num+1, total_num))
                # Imaginary portion set
                if self.use_imag and _np.iscomplexobj(data):
                    if self.rng is None:
                        ret_obj[idx] -= 1j*self._inst_als.calculate(data[idx].imag)
                    else:
                        ret_obj[idx][..., self.rng] -= 1j*self._inst_als.calculate(data[idx][..., self.rng].imag)
                else:  # Real portion set or real object
                    if self.rng is None:
                        ret_obj[idx] -= self._inst_als.calculate(data[idx].real)
                    else:
                        ret_obj[idx][..., self.rng] -= self._inst_als.calculate(data[idx][..., self.rng].real)
        except:
            return False
        else:
#            print(self._inst_als.__dict__)
            return True
nanops.py 文件源码 项目:PyDataLondon29-EmbarrassinglyParallelDAWithAWSLambda 作者: SignalMedia 项目源码 文件源码 阅读 41 收藏 0 点赞 0 评论 0
def _maybe_null_out(result, axis, mask):
    if axis is not None and getattr(result, 'ndim', False):
        null_mask = (mask.shape[axis] - mask.sum(axis)) == 0
        if np.any(null_mask):
            if np.iscomplexobj(result):
                result = result.astype('c16')
            else:
                result = result.astype('f8')
            result[null_mask] = np.nan
    elif result is not tslib.NaT:
        null_mask = mask.size - mask.sum()
        if null_mask == 0:
            result = np.nan

    return result
core.py 文件源码 项目:PyDataLondon29-EmbarrassinglyParallelDAWithAWSLambda 作者: SignalMedia 项目源码 文件源码 阅读 36 收藏 0 点赞 0 评论 0
def var(self, axis=None, dtype=None, out=None, ddof=0):
        ""
        # Easy case: nomask, business as usual
        if self._mask is nomask:
            return self._data.var(axis=axis, dtype=dtype, out=out, ddof=ddof)
        # Some data are masked, yay!
        cnt = self.count(axis=axis) - ddof
        danom = self.anom(axis=axis, dtype=dtype)
        if iscomplexobj(self):
            danom = umath.absolute(danom) ** 2
        else:
            danom *= danom
        dvar = divide(danom.sum(axis), cnt).view(type(self))
        # Apply the mask if it's not a scalar
        if dvar.ndim:
            dvar._mask = mask_or(self._mask.all(axis), (cnt <= 0))
            dvar._update_from(self)
        elif getattr(dvar, '_mask', False):
            # Make sure that masked is returned when the scalar is masked.
            dvar = masked
            if out is not None:
                if isinstance(out, MaskedArray):
                    out.flat = 0
                    out.__setmask__(True)
                elif out.dtype.kind in 'biu':
                    errmsg = "Masked data information would be lost in one or "\
                             "more location."
                    raise MaskError(errmsg)
                else:
                    out.flat = np.nan
                return out
        # In case with have an explicit output
        if out is not None:
            # Set the data
            out.flat = dvar
            # Set the mask if needed
            if isinstance(out, MaskedArray):
                out.__setmask__(dvar.mask)
            return out
        return dvar
core.py 文件源码 项目:aws-lambda-numpy 作者: vitolimandibhrata 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def var(self, axis=None, dtype=None, out=None, ddof=0):
        ""
        # Easy case: nomask, business as usual
        if self._mask is nomask:
            return self._data.var(axis=axis, dtype=dtype, out=out, ddof=ddof)
        # Some data are masked, yay!
        cnt = self.count(axis=axis) - ddof
        danom = self.anom(axis=axis, dtype=dtype)
        if iscomplexobj(self):
            danom = umath.absolute(danom) ** 2
        else:
            danom *= danom
        dvar = divide(danom.sum(axis), cnt).view(type(self))
        # Apply the mask if it's not a scalar
        if dvar.ndim:
            dvar._mask = mask_or(self._mask.all(axis), (cnt <= 0))
            dvar._update_from(self)
        elif getattr(dvar, '_mask', False):
            # Make sure that masked is returned when the scalar is masked.
            dvar = masked
            if out is not None:
                if isinstance(out, MaskedArray):
                    out.flat = 0
                    out.__setmask__(True)
                elif out.dtype.kind in 'biu':
                    errmsg = "Masked data information would be lost in one or "\
                             "more location."
                    raise MaskError(errmsg)
                else:
                    out.flat = np.nan
                return out
        # In case with have an explicit output
        if out is not None:
            # Set the data
            out.flat = dvar
            # Set the mask if needed
            if isinstance(out, MaskedArray):
                out.__setmask__(dvar.mask)
            return out
        return dvar
signal_models.py 文件源码 项目:parametrix 作者: vincentchoqueuse 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def get_nb_free_parameters(self):
        nb_free_parameters=0
        for parameter_name in self.estimated_parameters:
            parameter_value=np.ravel(getattr(self,parameter_name))
            if np.iscomplexobj(parameter_value)==True:
                nb_free_parameters=nb_free_parameters+2*len(parameter_value)
            else:
                nb_free_parameters=nb_free_parameters+len(parameter_value)

        return nb_free_parameters
signal_models.py 文件源码 项目:parametrix 作者: vincentchoqueuse 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def rvs(self):
        S=self.S
        N,M=S.shape
        iscomplex=self.iscomplex

        if iscomplex == None:
            iscomplex=np.iscomplexobj(S)

        if iscomplex==True:
            noise=self.noise.rvs(scale=np.sqrt(self.sigma2/2),size=(N,M))+1j*self.noise.rvs(scale=np.sqrt(self.sigma2/2),size=(N,M))
        else:
            noise=self.noise.rvs(scale=np.sqrt(self.sigma2),size=(N,M))

        return S+noise


问题


面经


文章

微信
公众号

扫码关注公众号