How to Calculate Mean & Variance of a Function

In summary: On to the next question!In summary, to simulate a function, you need to know: - What variables are random?- Are they independent?- What is the probability distribution function for each random variable?
  • #1
T.Engineer
87
0
Can anybody explain to me how to get the mean and the Variance for a specific function.
Thanks alot.
 
Physics news on Phys.org
  • #2
T.Engineer said:
Can anybody explain to me how to get the mean and the Variance for a specific function.
Thanks alot.

If you know exactly the pdf (probability density function) [tex]f(x)[/tex], the formula for the mean is
[tex]\mu = E[x] = \int x f(x) dx[/tex]
and for the variance
[tex]\sigma^{2} = E[(x - E[x])^{2}] = \int (x - E[x])^{2} f(x) dx[/tex]

If you only have experimental data, you can estimate the mean and variance of the distribution :
[tex]m = 1/N\times\sum_{i = 1}^{N} x_{i}[/tex]
[tex]s^{2} = 1/(N - 1)\times\sum_{i = 1}^{N} (x_{i} - m)^{2}[/tex]

Hope it helps
 
  • #3
For a specific function h of a random variable x with p.d.f. f(x),

Mean = E[h(x)] = ∫h(x)f(x) dx
Variance = E[(h(x) - Mean)^2] = ∫(h(x) - Mean)^2 f(x) dx

both integrated over the domain of f(x).

m = Σi h(xi)/N
s^2 = Σi (h(xi) - m)^2/(N-1)
 
Last edited:
  • #4
EnumaElish said:
For a specific function h of a random variable x with p.d.f. f(x),

Mean = E[h(x)] = ∫h(x)f(x) dx
Variance = E[(h(x) - Mean)^2] = ∫(h(x) - Mean)^2 f(x) dx

both integrated over the domain of f(x).

m = Σi h(xi)/N
s^2 = Σi (h(xi) - m)^2/(N-1)

for my function
Hn(t)= (-1)^n cos(2π fc t)* e^[(t^2)/4] *d^n/dt^n *e^[(t^2)/4]

what it will be h(x) and f(x)?
Thanks alot!
 
Last edited:
  • #5
For me to answer this, you should tell me what is random. (You need a random variable for this to work.) Are signal times (t) random? Is the time between two signals random? What is your random variable?
 
Last edited:
  • #6
EnumaElish said:
For me to answer this, you should tell me what is random. (You need a random variable for this to work.) Are signal times (t) random? Is the time between two signals random? What is your random variable?

n is also random variable.
 
  • #7
T.Engineer,

Please post the complete problem, exactly as it was given to you. You seem to be leaving out a lot of important information.

- Warren
 
  • #8
chroot said:
T.Engineer,

Please post the complete problem, exactly as it was given to you. You seem to be leaving out a lot of important information.

- Warren

I'd like to find the mean and variance for the following function
Hn(t)= (-1)^n cos(2π fc t)* e^[(t^2)/4] *d^n/dt^n *e^[(t^2)/4]

where n=1,2,...,N
fc=6.5MHz
 
  • #9
You can simulate this for a given n (random t).

You can simulate it for a given t and random n.

You can also simulate it with random t and random n.

You can collect the data and calculate the mean and the variance.
 
  • #10
EnumaElish said:
You can simulate this for a given n (random t).

You can simulate it for a given t and random n.

You can also simulate it with random t and random n.

You can collect the data and calculate the mean and the variance.

Thanks alot!
but I don't know how to start?
should I use the method which represented by
http://w3eos.whoi.edu/12.747/notes/lect06/l06s02.html
and if yes, how to enter my function to this simulation?
for example in the first equation , what did he mean by
yi, y
 
  • #11
Also I'd like to find an expression for the mean and variance in general not by just data.
first of all I want to find a mathematical expression for my function Hn(t).
Or , should firstly to find the data? and after that to find the mathematical expression for mean and variance of Hn(t)??
 
  • #12
EnumaElish said:
You can also simulate it with random t and random n.

You can collect the data and calculate the mean and the variance.

And sure I prefer to simulate with random t and random n.
But how?

Thanks alot!
 
  • #13
T.Engineer said:
Thanks alot!
but I don't know how to start?
should I use the method which represented by
http://w3eos.whoi.edu/12.747/notes/lect06/l06s02.html
and if yes, how to enter my function to this simulation?
for example in the first equation , what did he mean by
yi, y
yi is the i'th individual data point (function value). (y1 = first data point, y2 = second, ...)

"y bar" is the mean yi, calculated as the average of all the yi's:

y bar = Σi yi / N for i = 1, ..., N.

To simulate the function, you need to answer:
1. What variables are random?
2. Are they independent?
3. What is the probability distribution function for each random variable?

Your answers may be:
1. t and n (see footnote)
2. Yes
3. This is the difficult question. What determines the time at which the signal is emitted? Is it a random process like nuclear (radioactive) decay? And what determines n?

To start simple, you can assume ti is distributed uniformly between ti-1 and Ti, where Ti is an upper bound. Also assume n is uniformly distributed between 0 and M (a large number).

1. Let i = 0. Assume t0 = 0. Assume n0 = 0.
2. Let i = i + 1. Generate uniform random value ti between ti-1 and Ti (say, Ti = ti-1 + 1)
3. Generate uniform random value ni between 0 and M (say, M = 10)
4. Evaluate H[ni](ti).
5. Go to step 2.
_______________________________
Footnote: Although I don't understand why n is random, I am going with your statement that n is random.
 
Last edited:
  • #14
The transmitted signal represented by the function Hn(t)
which it will be transmitted according to time hopping format for kth users and given by :

S(t)= [tex]\sum^{\infty}_{j=-\infty} A^k Hn(t - jTf-cj Tc - rd^kj[/tex]

where A: is the signal amplitude
Hn(t): transmitted signal
Tf: is the frame time, which is typically a hundre to a thousand times
the impulse width resulting in a signal with very low duty cycle.
Each frame is divided into N tim slots with duration Tc
cj: time-hopping sequence (0<=cj<= N) with period Tc
This provides an additional shift in order to avoid catastrophic
collisions due to multipl access interference.
d: is the sequence of the MN-ary data stream generated by the kth
source after channel coding.
r :is the additional time shift utilized by the N-ary pulse positio
modulation.
I don't know if the above information is important for what I am going to determine?
thanks alot!
 
  • #15
It will take me some time to digest this information.

I thought Hn was only a function of t. See your earlier post https://www.physicsforums.com/showpost.php?p=1390181&postcount=4

How does the t in your last post relate to the t in your earlier post? Are they the same t? Do you mean to say Hn(#) = (-1)^n cos(2π fc #)* e^[(#^2)/4] *d^n/d#^n *e^[(#^2)/4] for some generic (general) argument # where # = t - jTf - cj Tc - r d^kj ?

If this is not it, what is it?

Assuming this is it, I advise you start simple by assuming t is uniformly distributed; you can easily change it later and replace it with a more complicated frequency distribution. I still do not understand why n is random; but if you think it is, then I am not going to argue with you. I will advise that you start simple and also assume n has a uniform frequency distribution.

Once you attach each of t and n to a frequency distribution, you can easily simulate your function to calculate the AC coefficient. You can also determine it analytically, by applying the formulas under this thread and under this other thread.
 
Last edited:
  • #16
EnumaElish said:
Are they the same t? Do you mean to say Hn(#) = (-1)^n cos(2π fc #)* e^[(#^2)/4] *d^n/d#^n *e^[(#^2)/4] for some generic (general) argument # where # = t - jTf - cj Tc - r d^kj ?

If this is not it, what is it?

yes, exactly! that's right!
 
  • #17
EnumaElish said:
I will advise that you start simple and also assume n has a uniform frequency distribution.

You mean firstly I will work for n=1, for example.
is not that right?
 
  • #18
EnumaElish said:
you mean to say Hn(#) = (-1)^n cos(2π fc #)* e^[(#^2)/4] *d^n/d#^n *e^[(#^2)/4] for some generic (general) argument # where # = t - jTf - cj Tc - r d^kj

Once you attach each of t and n to a frequency distribution, you can easily simulate your function to calculate the AC coefficient. You can also determine it analytically, by applying the formulas under this thread and under this other thread.

Now, can you tell me how to start and from where?
Really I get confused.
Thanks alot!
 

1. What is the formula for calculating the mean of a function?

The formula for calculating the mean of a function is to add up all the values of the function and then divide by the total number of values. This can be represented as:

Mean = (sum of all values) / (total number of values)

2. How do you find the variance of a function?

To find the variance of a function, you first need to calculate the mean of the function. Then, for each value in the function, subtract the mean and square the result. Finally, add up all the squared differences and divide by the total number of values. The formula for variance is:

Variance = (sum of squared differences) / (number of values)

3. What is the purpose of calculating the mean and variance of a function?

The mean and variance of a function are important statistical measures that help us understand the central tendency and variability of a set of data. They provide valuable information about the distribution of the data and can be used to make predictions and comparisons.

4. How can I use a function to calculate mean and variance in a programming language?

Many programming languages have built-in functions or libraries that can calculate mean and variance for a given set of data. For example, in Python, you can use the mean() and var() functions from the statistics module. In R, you can use the mean() and var() functions from the base package.

5. Can mean and variance be calculated for any type of function?

Yes, mean and variance can be calculated for any type of function as long as there is a set of data associated with it. However, it is important to note that the results may not be meaningful for all types of functions. For example, calculating the mean and variance of a quadratic function may not provide useful information as the function is not a representation of a set of data.

Similar threads

  • Set Theory, Logic, Probability, Statistics
Replies
6
Views
2K
  • Set Theory, Logic, Probability, Statistics
Replies
9
Views
887
  • Set Theory, Logic, Probability, Statistics
Replies
3
Views
671
  • Set Theory, Logic, Probability, Statistics
Replies
8
Views
449
  • Set Theory, Logic, Probability, Statistics
Replies
5
Views
239
  • Set Theory, Logic, Probability, Statistics
Replies
9
Views
1K
  • Set Theory, Logic, Probability, Statistics
Replies
6
Views
1K
  • Set Theory, Logic, Probability, Statistics
Replies
1
Views
1K
  • Set Theory, Logic, Probability, Statistics
Replies
3
Views
761
  • Set Theory, Logic, Probability, Statistics
Replies
11
Views
1K
Back
Top