0

For example if I have two multiplied distributions a * b:

d = np.random.normal(1,2,150000) * np.random.normal(1,3,150000)
mean_d = np.mean(d);  print(mean_d, '\t- mean d')
std_d = np.std(d);  print(std_d, '\t- std d')
var_d = np.var(d);  print(var_d, '\t- var d')

d = np.random.normal(0,2,150000) * np.random.normal(0,3,150000)
mean_d = np.mean(d);  print(mean_d, '\t- mean d')
std_d = np.std(d);  print(std_d, '\t- std d')
var_d = np.var(d);  print(var_d, '\t- var d')

d = np.random.normal(2,4,150000) * np.random.normal(3,6,150000)
mean_d = np.mean(d);  print(mean_d, '\t- mean d')
std_d = np.std(d);  print(std_d, '\t- std d')
var_d = np.var(d);  print(var_d, '\t- var d')

Result:

1.00402910382297    - mean d
7.006851762786954   - std d
49.09597162567064   - var d

-0.010013854223866369   - mean d
5.98944114495835    - std d
35.873405228919985  - var d

6.015273009526654   - mean d
29.412059046178683  - std d
865.0692173359013   - var d

Mean of the product calculated by multiplying mean values of each distribution mean_d = mean_a * mean_b. What is the formula for calculating variance or standard deviation?

Calculating using this formula:

def std_prod(x,y):
  return np.sqrt(np.mean(y)**2*np.std(x)**2 + np.mean(x)**2*np.std(y)**2 + np.std(y)**2*np.std(x)**2)

gives slightly different results:

7.004889924524913   - std d
6.983597750949972   - std_prod d

5.9967239637288525  - std d
5.9877281028408005  - std_prod d

29.315982668663818  - std d
29.305068878687155  - std_prod d
dereks
  • 101
  • 1
  • 2
  • Hi: you can take the log of the product so that you get the sum of two lognormals. Then, there should be some relatively easy way to figure out the mean and sd of that. But then you have to transform that back using the exponential in order to get back to the original product. The whole thing sounds slightly involved but it's a start. I have no comment on what you did because I didn't go through it but that's not the way to go about it. I hope this helps some to get you started. – mlofton Aug 29 '19 at 17:55
  • The standard deviation of the product of two normal distributions with means $\mu_{1}$ and $\mu_{2}$ and standard deviations $\sigma_1$ and $\sigma_2$ is $\sqrt{\mu _2^2 \sigma _1^2+\mu _1^2 \sigma _2^2+\sigma _2^2 \sigma _1^2}$. The variance is the square of that. – COOLSerdash Aug 29 '19 at 17:57
  • 1
    @COOLSerdash Thank you. What is the name for this formula? I'd like to google about where does this formula come from. – dereks Aug 29 '19 at 18:01
  • 1
    It follows from the properties of variances and expectations. See [here](https://stats.stackexchange.com/a/15986/21054) for a derivation. Also [here](https://stats.stackexchange.com/questions/52646/variance-of-product-of-multiple-random-variables). – COOLSerdash Aug 29 '19 at 18:05
  • @COOLSerdash Why does it return slightly different result? I updated the post. – dereks Aug 29 '19 at 18:26
  • 2
    Because your code is only *estimating* standard deviations from random samples. – whuber Aug 29 '19 at 18:30
  • @whuber You're right it is duplicate. But not for those who does not quite understand math notation. – dereks Aug 30 '19 at 09:42
  • Nor would it be a duplicate for someone who cannot read English. We have to make some assumptions here and the two most basic ones are that (1) questions and answers are expressed in English and (2) mathematical and quantitative relations are expressed in conventional mathematical notation. Although what is "conventional" will vary by community (just as what "English" means varies by country and region), there is little controversy about notations introduced in primary and secondary school (just as there is a basic English vocabulary and punctuation shared by all English speakers). – whuber Aug 30 '19 at 11:54

0 Answers0