ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 01 Jan 2014 14:11:34 +0100Probability density function - multivariate random variablehttps://ask.sagemath.org/question/10872/probability-density-function-multivariate-random-variable/Hi experts!
I know that many of you are professional mathematicians. My question is about statcistics and sage:
given two independient random variables `X` and `Y` (with a probability density function `fX` and `fY`), and the multivariable random variable `A` defined by: `A=h(X,Y)`,
How can I obtain the explicit equation of probability density function of random varible `A`?
I only know that the join probability density fuction `fXY` is `fXY=fX*fY` (because there are independent).
Like you can see in the article
http://en.wikipedia.org/wiki/Probability_density_function
section 'Multiple variables' we can write the pdf of `A` using Dirac delta function.
Waiting for your answers.
Thans a lot!!mresimulatorWed, 01 Jan 2014 14:11:34 +0100https://ask.sagemath.org/question/10872/How do I generate a random number according to the binomial distribution?https://ask.sagemath.org/question/8848/how-do-i-generate-a-random-number-according-to-the-binomial-distribution/I would like to generate a random integer according to the binomial distribution. That is, I would like to generate a Bin(n,p) random value. That's number between 0 and n in which the probability we get the value k is `C(n,k)p^k(1-p)^(n-k)`.
Here is an inefficient method (which requires n calls to `random()` ):
def bin_rv(n,p=0.5):
"""
Generate a binomial random variable with parameters n,p.
"""
return sum( random() < p for _ in range(n))
Is there a better way to do this (already built into Sage, I hope)?
(In Matlab, this can be done via the `binord` function and in R with the `rbinom` function.)Ed ScheinermanMon, 02 Apr 2012 15:50:18 +0200https://ask.sagemath.org/question/8848/