# Use RandomVariate with variable sigmas with values >= 0.2?

Posted 1 month ago
200 Views
|
0 Replies
|
0 Total Likes
|
 I have the followig script, where i need to create the random variable hm of 10^6 samples. My problem is that when i execute the RandomVariate function for the same inpute parameters, sometimes i get the random variable of 10^6 points and sometimes it returns the custom probability density function i provided as input. I saw that this happens when i set the variable sigmas with values equal or greater than 0.2. Could this be a bug? Nsamples = 10^6; (* Number of samples *) f = 350 10^9; (*GHz to Hz*) d = 60; (*distance m*) sigmas = 0.2; c = 299792458; (*m/s lightspeed*) Gtdb = 55; Grdb = 55; Gt = 10^(Gtdb/10); Gr = 10^(Grdb/10); lamda[f_] := c/f; (*wavelength in m*) heff = 1; Aeff[Gr_, f_] := (Gr lamda[f]^2)/(4 π heff); r[Gr_, f_] := Sqrt[(Aeff[Gr, f]/Pi) ]; Diam[Gr_, f_] := 2 r[Gr, f]; theta3dB[Gr_, f_] := 70 lamda[f]/Diam[Gr, f]; wd[d_, Gr_, f_] := d Tan[(theta3dB[Gr, f] (Pi/180))/2]; v[Gr_, f_, d_] := (Sqrt[Pi] r[Gr, f])/(Sqrt wd[d, Gr, f]); A0[Gr_, f_, d_] := Erf[v[Gr, f, d]]^2 ; weq2[d_, Gr_, f_] := (wd[d, Gr, f])^2 (Sqrt[π] Erf[v[Gr, f, d]])/( 2 v[Gr, f, d] Exp[-(v[Gr, f, d])^2]); Xi[d_, Gr_, f_] := weq2[d, Gr, f]/(4 (sigmas^2) ); X = Xi[d, Gr, f]; Ao = A0[Gr, f, d]; fhm[X_, Ao_, x_] := X/Ao^X x^(X - 1);(*PDF*) N[X] N[Ao] 0.304121 0.243095 Integrate[fhm[X, Ao, x], {x, 0, Ao}] 1. h = ProbabilityDistribution[fhm[X, Ao, x], {x, 0, Ao}]; hm = RandomVariate[h, Nsamples] hm[] 0.0943069 hm[] 0.0912831 hm1 = RandomVariate[h, Nsamples] RandomVariate[ProbabilityDistribution[(0.467567/x^0.695879),{x,0,Ao}],Nsamples] Answer