C RUBY-ON-RAILS MYSQL ASP.NET DEVELOPMENT RUBY .NET LINUX SQL-SERVER REGEX WINDOWS ALGORITHM ECLIPSE VISUAL-STUDIO STRING SVN PERFORMANCE APACHE-FLEX UNIT-TESTING SECURITY LINQ UNIX MATH EMAIL OOP LANGUAGE-AGNOSTIC VB6 MSBUILD

## using normal distribution and CSV in python Tag : python , By : Matt Leacock Date : November 29 2020, 04:01 AM

I wish this help you You can use random.gauss. Given a mean and standard deviation for a person, you create a random value based on a normal distribution as follows
``````from random import gauss

data = {'Person 1': (50.0, 0.0), 'Person 2': (100.0, 10.0), 'Person 3': (100.0, 5.0)}
# Randomize values based on a normal distribution
rand_data = {k: gauss(mu=v[0], sigma=v[1]) for k,v in data.items()}

# mu specifies mean and sigma specifies standard deviation
``````
``````from numpy.random import normal

data = {'Person 1': (50.0, 0.0), 'Person 2': (100.0, 10.0), 'Person 3': (100.0, 5.0)}
# Randomize values based on a normal distribution
rand_data = {k: normal(loc=v[0], scale=v[1]) for k,v in data.items()}

# loc specifies mean and scale specifies standard deviation
``````
``````{'Person 1': 50.0, 'Person 2': 104.66767928603309, 'Person 3': 90.49432247610861}
``````

Share :

## Find a python transformation function or numpy matrix to transform skewed normal distribution to normal distribution

Tag : python , By : snapshooter
Date : March 29 2020, 07:55 AM
this one helps. I've done one of 2 things:
Use box-cox transformations. This requires you find the appropriate power or lambda that transforms you data to having zero skew. Force a normal distribution.
``````from scipy.stats import norm

df = pd.DataFrame(np.random.rand(1000), columns=['Uniform'])
df['Normal'] = norm.ppf((df.Uniform.rank() - .5) / len(df))
df.plot(kind='kde')
``````
``````df.skew()

Uniform    2.392991e-02
Normal     2.114051e-15
dtype: float64
``````

## Mean and standard deviation in normal distribution and log-normal distribution

Tag : r , By : Manik
Date : March 29 2020, 07:55 AM
To fix this issue Below is my code: , Please read ?dlnorm:
`````` dlnorm(x, meanlog = 0, sdlog = 1, log = FALSE)
plnorm(q, meanlog = 0, sdlog = 1, lower.tail = TRUE, log.p = FALSE)
qlnorm(p, meanlog = 0, sdlog = 1, lower.tail = TRUE, log.p = FALSE)
rlnorm(n, meanlog = 0, sdlog = 1)

meanlog, sdlog: mean and standard deviation of the distribution on the
log scale with default values of ‘0’ and ‘1’ respectively.
``````

## How to generate following error distributions? (contaminated normal distribution, A normal heteroscedastic distribution

Tag : r , By : Nick Coats
Date : March 29 2020, 07:55 AM
seems to work fine In relation to your first question, as mentioned by @Glen_b, you could use e.g.:
`````` cont_norm <- function(n, # number of samples
mu = 0, # only one mu since the mean is the same for both distributions.
sd1 = 1, # sd of the first distr
sd2 = 102, # sd of the second distr
prob = 0.1 # contamination proportion
){
s <- sample(c(sd1, sd2), n, replace = T, prob = c(1 - prob, prob))
rnorm(n, mean = mu, sd = s)}

cont_norm(100, mu = 0, sd1 = 1, sd2 = 102, prob = 0.1)
``````

## How to transform a two dimensional normal distribution into a two dimensional lognorm distribution in python

Tag : python , By : Scott Everts
Date : March 29 2020, 07:55 AM
Hope that helps Here's the gist of it, I haven't tested it, but the logic is not too complicated . it might also be vectorizable for a speed up, but you have to map your linspaces into a single long array of 2D vectors.
``````dx = xMax - xMin
dy = yMax - yMin
c= (dx+dx/2.0,dy+dy/2.0)
z=np.array(shape=(N,M))
#Lets use a cartersian input vector space instead of polar
for i in range(len(xlinspace)):
for j in range(len(ylinspace)):
p=(xlinspace[i],ylinspace[j])
d= np.norm(p-c) # produce a distance form the centre for the smapled point
t=d #I'm just renaming distance to t to make it clear, this is an extra step as far as the program is concerned.
#Now put your lognorm logic here, i'll use f as a placeholder function
z[i][j]=f(t)
#You now have a 2d array of z outputs
``````

## How to get log-normal distribution (i.e. a normal distribution in dB) with a zero mean and a standard deviation of σ = 2

Tag : python , By : Ian Badcoe
Date : March 29 2020, 07:55 AM