Ejemplo n.º 1
0
def init_orbit(randomstat=1):
    #initial the basic param array for a system
    mass_pl=np.zeros(N_pl)
    a_pl=np.zeros(N_pl)
    r_pl=np.zeros(N_pl) #changed to radius rather than density


    #initial semi-major axis and masses of gas giant,
    #in solar units
    gpmass=3
    sesemi=1
    semass=2
    #fixed
    if gpmass==1:
        mass_pl[0]=1.e-3
        mass_pl[1]=1.e-3
        mass_pl[2]=1.e-3
    elif gpmass==2:
        #uniform in a mass range
        mass_pl[:3]=(0.5+np.random.random(3)*1.5)*1.e-3
    elif gpmass==3:
        mass_pl[:3]=(0.3+np.random.random(3)*2.7)*1.e-3

    a_inner,a_pl[:3]=set_hill(mass_pl[:3])
     ##need to move to setting file in the future
    if sesemi==1:
        a_pl[3]=0.1
        a_pl[4]=0.25
        a_pl[5]=0.5
    elif sesemi==2:
        a_pl[3:]=semi_major()

    #initial semi-major axis and masses of super earths,
    #in solar units
    M_earth=1./300./1000.

    if semass==1:
        mass_pl[3]=5*M_earth
        mass_pl[4]=10*M_earth
        mass_pl[5]=15*M_earth
    elif semass==2:
        marr=np.array([5.,10.,15.])
        sortindex=np.random.choice(3,3,False)
        print sortindex
        for i in xrange(3):
	        mass_pl[3+i]=marr[sortindex[i]]*M_earth

    r_pl[:3]=5e-4
    r_pl[3:]=1e-4

    #set up other orbital elements
    e_pl=rayleigh.rvs(scale=sigma_e,size=N_pl,random_state=randomstat)
    i_pl=rayleigh.rvs(scale=sigma_i,size=N_pl,random_state=randomstat+1000)
    np.random.seed(randomstat+2000)
    omega_pl=2.*np.pi*np.random.rand(N_pl)
    Omega_pl=2.*np.pi*np.random.rand(N_pl)
    M_pl=2.*np.pi*np.random.rand(N_pl)

    return [mass_pl,a_pl,r_pl,e_pl,i_pl,omega_pl,Omega_pl,M_pl]
Ejemplo n.º 2
0
def main():
    for i in xrange(1,max_runs+1):
        rundir="run%d" % i
        os.system("mkdir %s" % rundir)
        for ex in excutable:
            os.system("cp %s %s/" % (ex,rundir))
        for infile in inlist:
            os.system("cp %s %s/" % (infile,rundir))

        #initial the basic param array for a system
        mass_pl=np.zeros(N_pl)
        a_pl=np.zeros(N_pl)
        d_pl=np.zeros(N_pl)

        #initial semi-major axis and masses of gas giant,
        #in solar units
        mass_pl[0]=1.e-3
        mass_pl[1]=1.e-3
        mass_pl[2]=1.e-3

        a_inner,a_pl[:3]=set_hill(mass_pl[:3])

        #initial semi-major axis and masses of super earths,
        #in solar units
        M_earth=1./300./1000.
        mass_pl[3]=5*M_earth
        mass_pl[4]=10*M_earth
        mass_pl[5]=15*M_earth

        #need to move to setting file in the future
        a_pl[3]=0.1
        a_pl[4]=0.25
        a_pl[5]=0.5

        #need to modify in the future how this is set up
        d_pl[:2]=1.3
        d_pl[3:]=4.

        #set up other orbital elements
        e_pl=rayleigh.rvs(scale=sigma_e,size=6)
        i_pl=rayleigh.rvs(scale=sigma_i,size=6)
        g_pl=360.*np.random.randn(N_pl)
        n_pl=360.*np.random.randn(N_pl)
        M_pl=360.*np.random.randn(N_pl)
        t_max=t_orb*365.25*(a_inner)**1.5
        t_dump=t_max/1000.



        #write to big.in
        outfile = rundir+"/big.in"
        writetobig(mass_pl,a_pl,d_pl,e_pl,i_pl,g_pl,n_pl,M_pl,outfile)

        abspath=basename+rundir+"/"
        subfile=basename+rundir+"/submit_mercury"
        #subfile=rundir+"/submit_mercury"
        submit(abspath,subfile)
    return
Ejemplo n.º 3
0
 def select_transmitting_users(self):
     transmitting_users = []
     for user in self.users:
         user.csi = rayleigh.rvs()
         if user.csi >= self.communication_thresh:
             transmitting_users.append(user)
     return transmitting_users
Ejemplo n.º 4
0
def system_noise(nscan=200, noise_dist='gaussian', sigma=1, dim=None):
    """
    Generate system noise

    Args:
        nscan (int): Total time of design (in scans)
        noise_dist (string): Noise distribution, one of: "gaussian", "rayleigh"
        sigma (float): Sigma of noise distribution
        dim (list): XYZ Dimensions of output

    Returns:
        A ndarray [dim, nscan] with the noise timeseries

    Raises:
        Exception
    """
    # Handle the dim parameter
    mydim = _handle_dim(dim)
    mydim.append(nscan)

    if noise_dist == 'gaussian':
        return norm.rvs(scale=sigma, size=mydim)
    elif noise_dist == 'rayleigh':
        return rayleigh.rvs(scale=sigma, size=mydim)
    else:
        raise Exception('Unknown noise distribution provided: {}'.format(
                                                                  noise_dist))
Ejemplo n.º 5
0
def system_noise(nscan=200, noise_dist='gaussian', sigma=1, dim=None):
    """
    Generate system noise

    Args:
        nscan (int): Total time of design (in scans)
        noise_dist (string): Noise distribution, one of: "gaussian", "rayleigh"
        sigma (float): Sigma of noise distribution
        dim (list): XYZ Dimensions of output

    Returns:
        A ndarray [dim, nscan] with the noise timeseries

    Raises:
        Exception
    """
    # Handle the dim parameter
    mydim = _handle_dim(dim)
    mydim.append(nscan)

    if noise_dist == 'gaussian':
        return norm.rvs(scale=sigma, size=mydim)
    elif noise_dist == 'rayleigh':
        return rayleigh.rvs(scale=sigma, size=mydim)
    else:
        raise Exception(
            'Unknown noise distribution provided: {}'.format(noise_dist))
def user_dist_kstest(sim_dist_vec, diff_dist_vec, fit_rayleigh=False, _n=100):
    """ Test the goodness of a given weights to defferentiate friend distance
        distributions and non-friend distance distributions of a given user.
        The distance distribution can be assumed to follow Rayleigh distribution.

    Parameters:
    ----------
    sim_dist_vec: {vector-like (list), float}, distances between friends
                  and the user
    diff_dist_vec: {vector-like (list), float}, distances between non-fri
                   -ends and the user
    fit_rayleigh: {boolean}, determine if fit data into Rayleigth distri
                  -bution
    _n: {integer}, number of random samples generated from estimated
        distribution

    Returns:
    -------
    * res: {float}: p-value of ks-tests with assumption that distances follow
            Rayleigh distribution.

    Examples:
    ---------
    pval = user_dist_kstest(sim_dist_vec, diff_dist_vec)
    """

    # convert list to numpy.arrray, which can be
    # automatice transfer to R readable objects
    # for R-function, if the proper setting is
    # configured
    sim_dist_vec = np.array(sim_dist_vec)
    diff_dist_vec = np.array(diff_dist_vec)

    if fit_rayleigh:
        friend_param = rayleigh.fit(sim_dist_vec)
        nonfriend_param = rayleigh.fit(diff_dist_vec)

        samp_friend = rayleigh.rvs(friend_param[0], friend_param[1], _n)
        samp_nonfriend = rayleigh.rvs(nonfriend_param[0], nonfriend_param[1],
                                      _n)

        # ouput p-value of ks-tests
        test_stat, pval = kstest_2samp_greater(samp_friend, samp_nonfriend)
    else:
        test_stat, pval = kstest_2samp_greater(sim_dist_vec, diff_dist_vec)

    return pval
Ejemplo n.º 7
0
def user_dist_kstest(sim_dist_vec,
                     diff_dist_vec,
                     fit_rayleigh=False,
                     min_nobs=10,
                     _n=100):
    """ Test the goodness of a given weights to defferentiate friend distance
        distributions and non-friend distance distributions of a given user.
        The distance distribution is considered to follow Rayleigh distribution.

    Parameters:
    ----------
    sim_dist_vec: {vector-like (list), float}, distances between friends
                  and the user
    diff_dist_vec: {vector-like (list), float}, distances between non-fri
                   -ends and the user
    fit_rayleigh: {boolean}, determine if fit data into Rayleigth distri
                  -bution
    min_nobs: {integer}, minmum number of observations required for compar
              -ing
    _n: {integer}, number of random samples generated from estimated
        distribution

    Returns:
    -------
    * res: {float}: p-value of ks-test with assumption that distances follow
            Rayleigh distribution.

    Examples:
    ---------
    pval = user_dist_kstest(sim_dist_vec, diff_dist_vec)
    """
    # is_valid = (len(sim_dist_vec) >= min_nobs) & \
    #           (len(diff_dist_vec) >= min_nobs) # not used yet
    if fit_rayleigh:
        friend_param = rayleigh.fit(sim_dist_vec)
        nonfriend_param = rayleigh.fit(diff_dist_vec)

        samp_friend = rayleigh.rvs(friend_param[0], friend_param[1], _n)
        samp_nonfriend = rayleigh.rvs(nonfriend_param[0], nonfriend_param[1],
                                      _n)

        # ouput p-value of ks-test
        res = ks_2samp(samp_friend, samp_nonfriend)[1]
    else:
        res = ks_2samp(sim_dist_vec, diff_dist_vec)[1]
    return res
Ejemplo n.º 8
0
def AudioSpectrumData(t, Nbands):
    # Nbands = # of frequency bands
    npts = len(t)
    blms = np.zeros((npts, Nbands))
    for jj in range(Nbands):
        blms[:,jj] = rayleigh.rvs(size = npts)
    
    return blms
Ejemplo n.º 9
0
def ProximityData(t, d_0, dx, N):
    # average distance = d_0
    # movement scale is dx
    # number of prox sensors = N
    d = d_0 * np.ones((len(t), N))  # average distance is d_0 [m]
    for ii in range(len(t)):
        for jj in range(N):
            deltaX = rayleigh.rvs() - 1
            d[ii, jj] = d[ii - 1, jj] + deltaX

    return d
Ejemplo n.º 10
0
def init_orbit3(randomstat=1):
    M_earth=1./300./1000.
    R_earth = 6371./1.49e8
    density = 3*M_earth/(4*np.pi*R_earth**3)
    mass_pl = np.ones(N_pl)*M_earth*5
    r_pl = (3*mass_pl/(4*np.pi*density))**(1./3.)
    
    a_pl = np.zeros(N_pl)
    e_pl = np.zeros(N_pl)
    i_pl=rayleigh.rvs(scale=sigma_i,size=N_pl,random_state=randomstat+1000)
    omega_pl=2.*np.pi*np.random.rand(N_pl)
    Omega_pl=2.*np.pi*np.random.rand(N_pl)
    M_pl=2.*np.pi*np.random.rand(N_pl)
    a_pl[0] = 0.15
    e_pl = rayleigh.rvs(scale=0.15,size=N_pl,random_state=randomstat+1000)
    peri = a_pl[0]*(1+e_pl[0])*(1 - np.random.rand()/10.)
    a_pl[1] = peri/(1.-e_pl[1])

    accreting_planet = np.random.choice([0,1])
    mass_pl[accreting_planet]=12*M_earth
    r_pl[accreting_planet]=a_pl[accreting_planet]*(1-e_pl[accreting_planet])*(mass_pl[accreting_planet]/3)**(1./3.)
    
    return [mass_pl,a_pl,r_pl,e_pl,i_pl,omega_pl,Omega_pl,M_pl]
Ejemplo n.º 11
0
Archivo: gsm.py Proyecto: afcarl/isa
    def initialize(self, method='cauchy'):
        if method.lower() == 'student':
            self.scales = 1. / sqrt(gamma.rvs(1, 0, 1, size=self.num_scales))

        elif method.lower() == 'cauchy':
            self.scales = 1. / sqrt(gamma.rvs(0.5, 0, 2, size=self.num_scales))

        elif method.lower() == 'laplace':
            self.scales = rayleigh.rvs(size=self.num_scales)

        else:
            raise ValueError(
                'Unknown initialization method \'{0}\'.'.format(method))

        self.normalize()
 def getSamples(self, m=None):
     """
      Generates samples from the Rayleigh distribution.
      
      :param rayleigh self:
          An instance of the Rayleigh class.
      :param integer m:
          Number of random samples. If no value is provided, a default of     5e5 is assumed.
      :return:
          A N-by-1 vector that contains the samples.
     """
     if m is not None:
        number = m
     else: 
         number = 500000
     return rayleigh.rvs(loc=0.0, scale=self.scale, size=number, random_state=None)
Ejemplo n.º 13
0
    def get_samples(self, m=None):
        """
         Generates samples from the Rayleigh distribution.

         :param rayleigh self:
             An instance of the Rayleigh class.
         :param integer m:
             Number of random samples. If no value is provided, a default of     5e5 is assumed.
         :return:
             A N-by-1 vector that contains the samples.
        """
        if m is not None:
            number = m
        else:
            number = 500000
        return rayleigh.rvs(loc=0.0,
                            scale=self.scale,
                            size=number,
                            random_state=None)
Ejemplo n.º 14
0
	def initialize(self, method='student'):
		"""
		Randomly initializes parameters.
		"""

		if method.lower() == 'student':
			self.scales = 1. / sqrt(gamma.rvs(1, 0, 1, size=self.num_components))
			self.means *= 0.

		elif method.lower() == 'cauchy':
			self.scales = 1. / sqrt(gamma.rvs(0.5, 0, 2, size=self.num_components))
			self.means *= 0.

		elif method.lower() == 'laplace':
			self.scales = rayleigh.rvs(size=self.num_components)
			self.means *= 0.

		else:
			raise ValueError('Unknown initialization method \'{0}\'.'.format(method))
Ejemplo n.º 15
0
    def set_fake_counterparts(self, candidates):
        from scipy.stats import rayleigh
        
        # Assign fake counterparts
        idx_fake = np.random.choice(len(candidates), len(self))
        cat_fake = candidates[idx_fake]

        # Calculate coordinates for fake candidates
        # We randomize the positions of the fake counterpart around the
        # positions of the primary sources using a Rayleigh distribution
        mean_ra_fake = self.coords.ra.deg
        mean_dec_fake = self.coords.dec.deg

        # To estimate the variance for the Rayleigh distribution, we
        # circularize the errors of both catalogues:
        pcat_poserr_circ = self.poserr.transform_to('circle')
        cat_fake_poserr_circ = cat_fake.poserr.transform_to('circle')

        sig_fake = np.sqrt(
            (pcat_poserr_circ.components.columns[0].to(u.deg))**2 +
            (cat_fake_poserr_circ.components.columns[0].to(u.deg))**2
        )

        dr = rayleigh.rvs(loc=0.0, scale=sig_fake.value)
        theta = 2 * np.pi * np.random.random_sample(size=len(cat_fake))

        coords_ra_fake = mean_ra_fake + dr * np.cos(theta)
        coords_dec_fake = mean_dec_fake + dr * np.sin(theta)
        cat_fake.coords = SkyCoord(coords_ra_fake, coords_dec_fake, unit="deg")

        cat_fake.moc = self.moc
        cat_fake.area = self.area

        # We set the ids of the fake counterparts as the ids of this catalogue
        # for an easy identification of true counterparts
        cat_fake.ids = self.ids

        return cat_fake
Ejemplo n.º 16
0
def next_ttr(final_downtime_model, CRN=None):
    dist = final_downtime_model[0]
    params = final_downtime_model[1]

    if dist == "uniform":
        return uniform.rvs(*params, random_state=CRN)
    elif dist == "expon":
        return expon.rvs(*params, random_state=CRN)
    elif dist == "rayleigh":
        return rayleigh.rvs(*params, random_state=CRN)
    elif dist == "weibull_min":
        return weibull_min.rvs(*params, random_state=CRN)
    elif dist == "gamma":
        return gamma.rvs(*params, random_state=CRN)
    elif dist == "gengamma":
        return gengamma.rvs(*params, random_state=CRN)
    elif dist == "invgamma":
        return invgamma.rvs(*params, random_state=CRN)
    elif dist == "gompertz":
        return gompertz.rvs(*params, random_state=CRN)
    elif dist == "lognorm":
        return lognorm.rvs(*params, random_state=CRN)
    elif dist == "exponweib":
        return exponweib.rvs(*params, random_state=CRN)
Ejemplo n.º 17
0
from scipy.stats import norm, rayleigh
from numpy import linspace
from pylab import plot, show, hist, figure, title


""" here we try to fit rayleigh distribution to data
reference: glowingpython.blogspot.it"""

#generate 150 samples from a rayleigh distribution of mean 5 and std dev 2
samp = rayleigh.rvs(loc=5, scale=2, size=150)

#fit rayleigh distibution to generated samples
#param[0] & param[1] are mean and std. dev of fitted distribution
param = rayleigh.fit(samp)

#generate points on x-axis to plot
x = linspace(5, 13, 100)

#get the points on y-axis for fitted distribution
pdf_fitted = rayleigh.pdf(x, loc=param[0], scale=param[1])

#get the points on y-axis for original distribution
pdf = rayleigh.pdf(x, loc=5, scale=2)

title('Rayleigh distribution')
#plot the fitted distribution and original distribution
plot(x, pdf_fitted, 'r-', x, pdf, 'b-')
#histogram of normalized samples generated from rayleigh distribution
hist(samp, normed=1, alpha=0.3)

show()
Ejemplo n.º 18
0
# Display the probability density function (``pdf``):

x = np.linspace(rayleigh.ppf(0.01), rayleigh.ppf(0.99), 100)
ax.plot(x, rayleigh.pdf(x), 'r-', lw=5, alpha=0.6, label='rayleigh pdf')

# Alternatively, the distribution object can be called (as a function)
# to fix the shape, location and scale parameters. This returns a "frozen"
# RV object holding the given parameters fixed.

# Freeze the distribution and display the frozen ``pdf``:

rv = rayleigh()
ax.plot(x, rv.pdf(x), 'k-', lw=2, label='frozen pdf')

# Check accuracy of ``cdf`` and ``ppf``:

vals = rayleigh.ppf([0.001, 0.5, 0.999])
np.allclose([0.001, 0.5, 0.999], rayleigh.cdf(vals))
# True

# Generate random numbers:

r = rayleigh.rvs(size=1000)

# And compare the histogram:

ax.hist(r, density=True, histtype='stepfilled', alpha=0.2)
ax.legend(loc='best', frameon=False)
plt.show()
Ejemplo n.º 19
0
def init_orbit(runnumber, small_WJ_radius = True):
    #initial the basic param array for a system
    
    mass_pl=np.zeros(N_pl)
    a_pl=np.zeros(N_pl)
    r_pl=np.zeros(N_pl) #changed to radius rather than density

    #a_inner,a_pl[:3]=set_hill(mass_pl[:3])

    #initial semi-major axis and masses of super earths,
    #in solar units
    M_earth=1./300./1000.
    R_earth = 6371./1.49e8
    density = 3*M_earth/(4*np.pi*R_earth**3)
    loop = True

    seeds=(np.random.rand(500)*1000).astype(int) # this serie is likely to be the same for your paralleal runs (at least for those in the same node, but will be different between different trials [today's run and next week's run])
    
    newseed = seeds[runnumber] # this operation ensure the seed between the runs are different. 
    np.random.seed(newseed) #use the new seed

#draw orbital element below without randomstat argument

    while (loop==True):
    #set up other orbital elements
        e_pl=rayleigh.rvs(scale=sigma_e,size=N_pl)
        i_pl=rayleigh.rvs(scale=sigma_i,size=N_pl)
        
        omega_pl=2.*np.pi*np.random.rand(N_pl)
        Omega_pl=2.*np.pi*np.random.rand(N_pl)
        M_pl=2.*np.pi*np.random.rand(N_pl)
        mass_pl = np.random.normal(loc=5*M_earth,scale = 2*M_earth,size=N_pl)
        if any(mass_pl<0.5*M_earth) or any(mass_pl>10*M_earth): #ensures mass is between 0.5 and 10 Earth Masses
            continue
        r_pl =(3*mass_pl/(4*np.pi*density))**(1./3.)
        K = np.random.normal(loc=k_Hill,scale=2)
        if K <=0: #ensures seperation between planets is positive
            continue
        P_min =rayleigh.rvs(scale=P_inner/(365.))
        a_min = P_min**(2./3.)

        in_range=[]
        a_pl[0] = a_min
        
        for i in range(1,N_pl): #set up ladder of planets 
            m_ratio = 2*(3/(mass_pl[i-1]+mass_pl[i]))**(1./3.)
            a_pl[i] =(K/m_ratio + 1)/(1 - K/m_ratio)*a_pl[i-1]
            if a_pl[i]>0.1 and a_pl[i]<0.4:
                in_range.append(i)
        if len(in_range)>0: #ensures there is always at least 1 planet in the WJ range
            accreting_planet = np.random.choice(in_range)
            if accreting_planet > N_pl-2: #ensures each WJ has at least 2 outer neighbors
                continue
            mass_pl[accreting_planet]=12*M_earth
            loop=False
            if small_WJ_radius: #settings for different Warm Jupiter radii
                r_pl[accreting_planet]=a_pl[accreting_planet]*(1-e_pl[accreting_planet])*(mass_pl[accreting_planet]/3)**(1./3.)/10.
            else:
                r_pl[accreting_planet]=a_pl[accreting_planet]*(1-e_pl[accreting_planet])*(mass_pl[accreting_planet]/3)**(1./3.)
            for i in range(accreting_planet,N_pl): #adjust ladder of planets for WJ
                if i>0:
                    m_ratio = 2*(3/(mass_pl[i-1]+mass_pl[i]))**(1./3.)
                    a_pl[i] =(K/m_ratio + 1)/(1 - K/m_ratio)*a_pl[i-1]
    #print mass_pl, a_pl, r_pl, e_pl, i_pl, omega_pl, Omega_pl, M_pl
    return [mass_pl,a_pl,r_pl,e_pl,i_pl,omega_pl,Omega_pl,M_pl]
Ejemplo n.º 20
0
from scipy.stats import rayleigh
import seaborn as sb
import matplotlib.pyplot as plt
c = rayleigh.rvs(0.5,size=10000)
ax = sb.distplot(c,kde=True,color='crimson',hist_kws={"linewidth": 25,'alpha':1})
ax.set(xlabel='Rayleigh', ylabel='Frequency')
plt.show()


from scipy.stats import norm, rayleigh
from numpy import linspace
from pylab import plot, show, hist, figure, title

# 依照 rayleigh 分布產生數據
y = rayleigh.rvs(loc=5, scale=2, size=150)
# fitting
param = rayleigh.fit(y)
# 畫圖
x = linspace(5, 13, 100)
# fitted distribution
pdf_fitted = rayleigh.pdf(x, loc=param[0], scale=param[1])
# original distribution
pdf = rayleigh.pdf(x, loc=5, scale=2)

title('Rayleigh distribution')
plot(x, pdf_fitted, 'r-', x, pdf, 'b-')
# hist(y, normed=1, alpha=.3)
hist(y, density=1, alpha=.3)
show()
Ejemplo n.º 22
0
 def gen_sample(self, n):
     return rayleigh.rvs(loc=self.mu, scale=self.sigma, size=n)
Ejemplo n.º 23
0
 def rayleigh_ch(self):
     rch=rayleigh.rvs(size=len(self.modulated))
     self.rch_mod=self.modulated+rch
     return self.rch_mod
Ejemplo n.º 25
0
from scipy.stats import rayleigh
import numpy as np
import matplotlib.pyplot as plt

a = rayleigh.rvs(2, size=100)
print(float(np.mean(a)))
print(np.std(a))
plt.hist(a, bins=10, density=True, color='green')
plt.xlabel('$x$')
plt.ylabel('$y$')
plt.show()
Ejemplo n.º 26
0
from scipy.stats import norm, rayleigh
import matplotlib.pyplot as plt
import matplotlib.mlab as mlab
import numpy as np

samp = rayleigh.rvs(loc=5, scale=2, size=150)  # samples generation

print(samp)
param = rayleigh.fit(samp)  # distribution fitting

x = np.linspace(5, 13, 100)
# fitted distribution
pdf_fitted = rayleigh.pdf(x, loc=param[0], scale=param[1])
# original distribution
pdf = rayleigh.pdf(x, loc=5, scale=2)

plt.title('Rayleigh distribution')
plt.plot(x, pdf_fitted, 'r-', x, pdf, 'b-')
plt.hist(samp, normed=1, alpha=.3)
plt.show()
def rf1():
    return rayleigh.rvs(sigma_rayleigh, size = n)