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, 08 Nov 2023 14:13:47 +0100Calculating very complex probability equationhttps://ask.sagemath.org/question/74237/calculating-very-complex-probability-equation/ I want to calculate the probability of following statement. It will be very close to $1$ ,but I need to see how close it is.
I could not calculate it using standart python, so I need very sensitive tool. I think that sage can handle it. However, I could not take proper solution. Maybe, i am missing something. $$\frac{(39 \times 10^{96})!}{(39 \times 10^{96}-16 \times10^9)! \times (39 \times 10^{96})^{16 \times10^9}}$$jacopWed, 08 Nov 2023 14:13:47 +0100https://ask.sagemath.org/question/74237/Plotting a Probability distribution with varying parameterhttps://ask.sagemath.org/question/69787/plotting-a-probability-distribution-with-varying-parameter/Suppose I wish to plot the function
import numpy as np
var('a,y')
A=np.linspace(-1,1,10)
for a in A:
z=a+x-(e^(-y^2/2))/sqrt((2*pi))
plot3d(z,(x,-1,1),(y,-1,1))
That is, I wish to plot the function `z` over a range of `a`. Actually the original function was `z=a+x`. But, in order to introduce randomization, I changed the variable `x` to `x-y'`, where `y'` is the standard normal variable. I wish to obtain the plot of `z` as a kind of variable probability distribution over the grid of `x` and `y` with the variation of `a` (so kind of series of probability distributions overlapping each other). How do I do this? Any hints? Thanks beforehand.vidyarthiFri, 07 Jul 2023 12:32:51 +0200https://ask.sagemath.org/question/69787/show that probability of throwing TEE is greater then 1?64https://ask.sagemath.org/question/65922/show-that-probability-of-throwing-tee-is-greater-then-164/ Emma makes a straight prism with an equilateral triangle as its base from a net labeled as shown in the adjacent figure. She uses the prism as a 'dice, where the letter at the bottom is considered to be rolled.
Show: If the probability of rolling M A T H E is greater than the probability of rolling EM M A, then the probability of rolling T E E is greater than 1/64AngelinaSat, 14 Jan 2023 15:22:37 +0100https://ask.sagemath.org/question/65922/Random matrix with density.https://ask.sagemath.org/question/65899/random-matrix-with-density/ I have a little question of comprehension
random_matrix(ZZ, 5, 4, x=0,y=11, density = 0.33)
generate a result like
[0 6 0 0]
[0 5 0 0]
[5 0 0 0]
[0 0 0 4]
but this gives 5 non zero enters which correspond, as I undeerstand it, to a density of 5/25 which is very far from .33 ?
As always I suppose I have not clearly understood the meaning of `density`.
Should somebody explain this ?
CyrilleFri, 13 Jan 2023 18:24:47 +0100https://ask.sagemath.org/question/65899/effective value in pokerhttps://ask.sagemath.org/question/61869/effective-value-in-poker/i've been studying expected value and all of the exemples are about coins or dices. I understand how to apply the formula in those exemples, but what about something more complexe like poker?
I think the amount you can win is the amount of money in the pot that is not yours.
And the amount of money you can lose is the amount of money in the pot that is yours, but what about your probability to win or lose?
I know my question is vague but i don't even know how to start thinking about applying ev in a complex game like poker so any exemple would be great to at least oriente my research
And note that i'm not a mathematician so i will need baby stepsSolarchickThu, 07 Apr 2022 20:32:28 +0200https://ask.sagemath.org/question/61869/Expected value of random variableshttps://ask.sagemath.org/question/44997/expected-value-of-random-variables/ I'm new to SAGE and just getting my feet wet. Would greatly appreciate if someone could point me to how to calculate the following using SAGE:
Say I have an event drawn from a Poisson distribution that happens on average once a year. I'd like to define a random variable and then calculate the following:
1. Probability the event will occur after 1 month (1/12th of a year)
2. Probability the event will not occur for 2 years but will occur during the third year.
I've searched unsuccessfully for how to do this and would greatly appreciate any help.kyesledgeThu, 10 Jan 2019 21:33:00 +0100https://ask.sagemath.org/question/44997/How to generate an element from laplace distributionhttps://ask.sagemath.org/question/26617/how-to-generate-an-element-from-laplace-distribution/ Hi, I am wondering how to generate a random element according to laplace distribution.
I tried the method RealDistribution(). But it failed.
According to the reference manual, laplace distribution is not supported.
http://www.sagemath.org/doc/reference/probability/sage/gsl/probability_distribution.html
In the manual, there are some examples showing how to deal with uniform distribution, Gaussian distribution, etc.
My questions are:
(1) How do I know exactly which distributions are supported by the RealDistribution() method?
(2) Is there anyway I can simply generate an element according to laplace distribution in sage?
Thank you in advance. qbyteTue, 21 Apr 2015 21:57:56 +0200https://ask.sagemath.org/question/26617/Use cumulative distribution functionshttps://ask.sagemath.org/question/35407/use-cumulative-distribution-functions/I don't understand how to use cumulative distribution functions in sagemath.
For example, I'd like to define a function *N(x)* as *N(x)=1-F(x)* where *F* is a cumulative log-normal distribution
However, if I try
W = RealDistribution('lognormal',[1.5,.6])
N(x) = W.cum_distribution_function(x)
it does not seem to work at allMassimo2013Thu, 03 Nov 2016 23:57:25 +0100https://ask.sagemath.org/question/35407/Unexpected Answer for an Equationhttps://ask.sagemath.org/question/33254/unexpected-answer-for-an-equation/ Hello,
I am trying to calculate the following equation in SAGE.
N = 100.
p = 0.9.
r = (N /(N-1))*(ln(N)-ln(-ln(p))); r
Unfortunately, sage gives this answer **100/99*log(100) + 2.27309831041661** , which is not the expected answer !!
But, when I used google calculator, I got the expected answer, which is **6.92478536697**
Please let me know what is going on.? Thank you. usamrfThu, 28 Apr 2016 20:52:10 +0200https://ask.sagemath.org/question/33254/How to use the DiscreteRandomVariable class?https://ask.sagemath.org/question/31182/how-to-use-the-discreterandomvariable-class/The [reference manual](http://doc.sagemath.org/html/en/reference/probability/sage/probability/random_variable.html#sage.probability.random_variable.DiscreteRandomVariable ) talks about DiscreteRandomVariable class. But, I do not understand how it should be initialized? There are variables "X" and "f" but the docs do not explain what they are, nor there is any example...
Additionally: is it possible to calculate functions on DiscreteRandomVariables? E.g, if X and Y are random variables, can I write "Z = X * Y" and have a new random variable Z?
Erel Segal-HaleviSun, 29 Nov 2015 16:52:11 +0100https://ask.sagemath.org/question/31182/Probability dice question, need to know if i am right?https://ask.sagemath.org/question/27257/probability-dice-question-need-to-know-if-i-am-right/Suppose that we have 2 dice, one Red and one Black. The Red die is defective, the probability to get 6 is 1/3. Now if we throw the 2 dice and get equal values the Black one wins, obviously if one is bigger that one wins. Which one of the dice has the biggest probability to win?
My solution:
P(red die for not rolling six) = 1 - 1/3 = 2/3
Since there are 5 other possible values we have P(red die for each value) = 2/3 * 1/5 = 2/15
Now for the Red Die to win we have 15 possibilities: (1,2) (1,3) (1,4) (1,5) (1,6*) (2,3) (2,4) (2,5) (2,6*) (3,4) (3,5) (3,6*) (4,5) (4,6*) (5,6*) => Of which 5 have 6 in it. While for the Black one 21 of which 1 have 6 in it.
P(red to win) = 10 * (1/6 * 2/15) + 5 * (1/6 * 1/3) = .5
P(black to win) = 20 * (1/6 * 2/15) + 1 * (1/6 * 1/3) = .5
Both have equal possibilities to win, however from some teacher notes it says that the Black one has the biggest probability to win and i don't know why.
Please help!blinbvSat, 04 Jul 2015 02:36:44 +0200https://ask.sagemath.org/question/27257/How to use DiscreteRandomVariable covariance method?https://ask.sagemath.org/question/26379/how-to-use-discreterandomvariable-covariance-method/I'd like to take advantage of covariance() method of DiscreteRandomVariable class, yet, I can't find any example on the internet how to properly use it.
My understanding is that this should work:
text1 = AlphabeticStrings().encoding("AB")
text2 = AlphabeticStrings().encoding("BA")
text1freq = frequency_distribution(text1)
text2freq = frequency_distribution(text2)
text1freq.covariance(text2freq)
However, I receive unexpected ValueError:
/usr/lib/python2.7/site-packages/sage/probability/random_variable.pyc in covariance(self, other)
187 Omega = self.probability_space()
188 if Omega != other.probability_space():
--> 189 raise ValueError("Argument other (= %s) must be defined on the same probability space." % other)
190 muX = self.expectation()
191 muY = other.expectation()
ValueError: Argument other (= Discrete probability space defined by {A: 0.500000000000000, B: 0.500000000000000}) must be defined on the same probability space.
But... Logically (not technically) both text1freq and text2freq are the same probability space:
sage: text1freq
Discrete probability space defined by {A: 0.500000000000000, B: 0.500000000000000}
sage: text2freq
Discrete probability space defined by {A: 0.500000000000000, B: 0.500000000000000}
browning0Mon, 30 Mar 2015 10:39:01 +0200https://ask.sagemath.org/question/26379/multivariate integralhttps://ask.sagemath.org/question/10875/multivariate-integral/Hi experts!
For obtain the pdf of a multivariate function of random variables i must resolve explicitly a multivariate integral and then derivate it:
http://math.stackexchange.com/questions/624958/how-to-obtain-a-pdf-of-a-random-variable-defined-as-a-function-of-many-variables/
How can I resolve my problem in SAGE?
Waiting for yor answers.
Thanks a lot!!
mresimulatorThu, 02 Jan 2014 13:01:11 +0100https://ask.sagemath.org/question/10875/1/100 probability, based off infinite trials.https://ask.sagemath.org/question/10411/1100-probability-based-off-infinite-trials/Okay soo i was reading around on probabilities and i found a page where it talks about probabilities, 1/100 and what are the chances that the 1/100 thing occurs. I couldnt help but feel this is wrong because probabilities in general are based off an infinite amount of trials assuming that its always the best possible outcome.
Specifically, this link. http://answers.yahoo.com/question/index?qid=20080126081910AAdbGVx
Heres an example.
A crate has a 1% chance to have a special item. That means that according to an infinite amount of trials, and best possible outcome, 1/100 crates will have a special item in them. Even though the probability doesnt change, the best possible outcome would suggest that this would always happen in an infinite trail.
This is correct, right ? Or is there something major im missing ?
randomness000Sat, 03 Aug 2013 21:27:15 +0200https://ask.sagemath.org/question/10411/Probability density functionhttps://ask.sagemath.org/question/10242/probability-density-function/Hi experts!
In a line like this:
uniforme_x=RealDistribution('uniform',[a,b])
i call a 'uniform' probability density function: `f(t)=1/(b-a)`, `a<t<b`.
In addition, SAGE includes several probability density function: gaussian, log-normal, etc.
But: How can create in SAGE a probability density function created by me (F(t), DIFFERENT to gaussian, log-normal, etc...) and then create random numbers from it?
Waiting for your answers.
Thanks a lot.
mresimulatorFri, 14 Jun 2013 20:00:45 +0200https://ask.sagemath.org/question/10242/Seed - probability distribution functionshttps://ask.sagemath.org/question/10194/seed-probability-distribution-functions/Hello experts!
In a new user of sage.
This is a triple-question for you:
1) Reading the 'Craig Finch Sage Beginners Guide' page 236 I find the next script (about accessing probability distribution functions):
variance = 0.75
gaussian = RealDistribution('gaussian', variance)
gaussian.set_seed(0.0)
random_values = [gaussian.get_random_element() for i in range(1000)]
gaussian_plot = gaussian.plot((-5, 5))
The 1st question is ¿Whats for gaussian.set_seed(0.0)? ¿What does (0.0) seed value minds?
2) ¿What must i write in a script for obtain a normal (gaussian) distribution center in 'C' with variance 'V'?
3) Again, in 'Craig Finch Sage Beginners Guide' page 305 i find:
rng = RealDistribution('uniform', [0,dimension], seed=1)
¿Whats for seed=1 value? ¿What does 1 seed value minds?
Waiting for your answers.
Thaks a lot!!mresimulatorWed, 05 Jun 2013 18:38:47 +0200https://ask.sagemath.org/question/10194/Best way to handle probability distributionshttps://ask.sagemath.org/question/9480/best-way-to-handle-probability-distributions/I'm curious to know what people recommend as the best way to handle probability distributions in Sage. Using scipy requires setting up a lambda function when doing a plot, and RealDistribution only accepts one parameter (standard deviation) for the normal distribution when there should be two. Is there a better option?calc314Sun, 28 Oct 2012 23:15:51 +0100https://ask.sagemath.org/question/9480/Probability space valued functionshttps://ask.sagemath.org/question/9428/probability-space-valued-functions/I am trying to define a FiniteProbabilitySpace whose probabilities depend on a value x:
**var('x')
S=[-1,0,1]
P={}
P[1] = lambda x: x
P[-1] = lambda x: x
P[0] = lambda x: 1.-2*x
Sp = DiscreteProbabilitySpace(S,P)**
Then if I say **Sp.entropy()**, I get the result:
**TypeError: bad operand type for unary -: 'function'**
which seems logic, I did not determine x. But if I say **Sp(0).entropy()**, I get:
**TypeError: Unable to convert x (='<function<lambda>at0xa65d2a8>') to real number.**
I do not understand this. Is it possible to do what I want?
Thank you very much!Juan SimoesMon, 15 Oct 2012 12:46:16 +0200https://ask.sagemath.org/question/9428/how to calculate in SAGE the cumulative distribution function of a "stable distribution"?https://ask.sagemath.org/question/8874/how-to-calculate-in-sage-the-cumulative-distribution-function-of-a-stable-distribution/A stable distribution, defined in [wiki](http://en.wikipedia.org/wiki/L%C3%A9vy_skew_alpha-stable_distribution) is basically defined by,
> In probability theory, a random variable is said to be stable (or to have a stable distribution) if it has the property that a linear combination of two independent copies of the variable has the same distribution, up to location and scale parameters.
As far as I know, the family of stable
distributions is defined by four
parameters: mu, c, alpha and beta. I
need to generate random numbers
according to a given stable
distribution, that is, to a given
choice of the parameters of the stable
distribution family.
How can it be done in SAGE? Is there some "statistical package" which provides this?
Best regards.juanpoolWed, 11 Apr 2012 18:56:26 +0200https://ask.sagemath.org/question/8874/