Difference between function and distribution? I have constant function as $$y = exp(-x^2)$$ 
This also represent gaussian distribution with mean zero and variance of 0.5 Now if we take sample from this function, which will always be from this distribution.
Now, if we estimate the behaviour of this function by taking few sample from it and fit a curve. Then we generally say that this is function not a distribution.
Is this because of we are not considering mean and variance while estimating?
 A: Small corrections and notes: 


*

*y should be $\frac{1}{\sqrt{\pi}}exp(-x^2)$ to be a density function. This density, as you say, represents a Gaussian distribution with specific mean/variance.  

*Distribution function is referred as CDF, which is the integral of the density function.


Now, let's clear the ambiguity. Sampling from a function means calculating a couple of outputs given a couple of inputs, i.e. you'll have samples like $f(x_1),f(x_2)...,f(x_n)$ given $x_1,...,x_n$. You can fit a curve to these samples and say that this is a function, yes. This is like sampling a signal, and is unrelated to the sampling we do in probabilistic framework. 
When you create samples from distributions, you create random numbers whose histogram resembles the density function they're sampled from. This random number creation (sampling) process is often tedious. A common approach is Inverse Transform Sampling, which is first creating a uniform RV $u$ (between 0,1), which is another problem, and applying $F^{-1}(u)$, where $F(x)$ is CDF of the random variable we're interested in. For creating Gauss RV, there is Box-Muller method.
To sum up, sampling from a distribution is like making up a histogram, other than plotting $y$ curve.
