Questions tagged [probability]
Consider if your question would be better at stats.stackexchange.com. Probability touches upon uncertainty, random phenomena, random numbers, random variables, probability distributions, sampling, combinatorics.
4,046
questions
0
votes
0
answers
16
views
Statistics Inference Question: Prob(An equation) = 1 v.s. The equation holds
When I study the textbook Statistical Inference by Casella and Berger, I have seen a lot lot time the expressions in the form of P(an equation) = 1. However, in some other textbook or lecture notes, ...
0
votes
2
answers
47
views
How to calculate the expected number of attempts needed to succeed once when the probability increases with each failure?
Let's say the base probability of success is .03 and each failed attempt increases the probability by .002 so that the second attempt has a probability of .032, the third .034, and so on. How can I ...
0
votes
0
answers
15
views
glmnet lasso in R erroring
I'm running a negative binomial lasso in R using glmnet with package version 4.0-2
No matter how much I trim down the data, I get an error due that reads
Error: inner loop 1; cannot correct step size
...
-1
votes
0
answers
18
views
Creation of a Transitional Probability Matrix in Python or R: How to proceed?
I need to create a transitional matrix, but I've never done this before and I would like to do it on Python or R.
I am used to work with stata, so I am beginner in Python and R.
So, to give a bit of ...
0
votes
0
answers
27
views
Getting probability values much higher while fitting the GMM using sklearn
I am trying to fit the GMM to my data which are in 2d , they are small values around 0.002342(like this) so while fitting the GMM , I am getting some probability values very high , below is the code ...
0
votes
1
answer
20
views
How to modify the Birthday Problem to answer the probability of 3, 4, 5 or more people in a room having the same birthday
The Birthday Problem asks how many people need to be in a room for there to be greater than a 50% chance that at least two people have the same birthday. I've used the Python code below to solve for ...
0
votes
0
answers
36
views
Excel VBA integration using trapezoidal rule
I am trying to solve the equation shown in the attached image which basically get the probability of each wind speed and multiply it by the flare efficiency for that wind speed.
I am trying to solve ...
1
vote
2
answers
32
views
How to find the probability cutoff that maximize inner product of two tensors?
I have two tensors:
import torch
target = torch.randint(2, (3,5)) #tensor of 0s & 1s
pred = torch.rand(3, 5) #tensor of prob
# transformed_pred = ?
How can I choose a cutoff probability to ...
0
votes
0
answers
20
views
An Inequality of Conditional Expected Value
I'm trying to understand the following inequality. Inequality marked with (*), as described in the paper, is because of indecency of some random variables. Considering the information and description ...
0
votes
0
answers
29
views
Python generate 3 correlated array of random noise with different distributions
I need to generate random noise for 3 variables, i.e. X, Y and Z. I need X to be lognormal, and Y and Z is normal. The correlation matrix should be:
1, -0.8, 0.5
-, 1, -0.5
0.5,-0.5, 1
The std of ...
0
votes
0
answers
22
views
Naive Bayes classification for multivalued marginal [migrated]
x
y
z
C
1
0
1
1
1
1
1
1
0
1
1
0
1
1
0
0
1
0
1
0
0
0
0
1
0
0
0
1
0
0
1
0
The dataset in the table above consisting of boolean variables x,
y and z and a single boolean output variable C. I ...
0
votes
0
answers
36
views
Hyperloglog result improvements
I came to know about HyperLogLog to count distinct elements in a large dataset. So tried using for API call responses.
The code collects ids from the list of ids in the response.
The list of ids are ...
0
votes
0
answers
27
views
Question about transition matrix Q in D3PM diffusion model for discrete state space
I have a question related to the following equations which are addressed in the section 3 of D3PM (Austin et al., 2021, NIPS, arXiv: 2107.03006v3: https://arxiv.org/pdf/2107.03006.pdf).
It's about ...
1
vote
1
answer
46
views
Scipy stats t-test for the means and degrees of freedom
I am using the stats module from scipy and in particular the function ttest_ind. I want to extract information related to the degrees of freedom when I apply this test. According to the SciPy v1.11.4 ...
0
votes
0
answers
17
views
Finding the area (Probability) under a non parametric PDF
How would i go about calculating the area (Probability) betweeen 2 points under a non parametric PDF for a given set of x and y data?
Is there a package in python/scipy/statsmodels that allows me to ...
0
votes
2
answers
51
views
How can I calculate transition probabilities trial by trial?
I have a pandas dataframe consisting of zeros and ones. The first 20 trials are called block 1 and next 20 are called block 2. Each row indicates a trial, so there are in total 40 trials. I want to ...
-1
votes
1
answer
57
views
Computer Virus Spread Simulation - How to make each trial have random outputs?
This code is used to simulate the virus spread in the network of 20 computers with the probability of 0.1 ~ 10%. It initially starts with only 1 computer being infected and each day has a chance that ...
1
vote
2
answers
46
views
Runtime of randomization algorithm to find majority element in an array?
This is for the leetcode problem 169. Majority Element. Given an array of numbers, where there is a guarantee that there is a number that exists in the array greater than floor(n/2), one can find such ...
-1
votes
1
answer
64
views
Convert a list with a sum of 1 and keep the relations between the values [duplicate]
Assume there is a list[int] like this:
[0, 2, 3, 3, 0, 9]
I want to convert it to list[float] with a sum of 1 and keep the relations between the values:
[a, b, c, d, e, f]
# a = e = 0
# c = d
# f = ...
0
votes
1
answer
28
views
Predict the next value based on the existing data of 100k values
I'm having a dataset contains 100000 values of the previous results. Based on that, I'd like to predict the next value.
The dataset looks like this.
0
1
1
1
0
0
1
0
1
0
0
0
0
1
.
..
...
Based on these ...
1
vote
0
answers
40
views
How many random bits does this algoithm use on average (expected value)?
Here, flip() is a function that returns 0 or 1 with equal probability. It can be proved function Random(n) returns a number from 0 to n-1 with identically distributed probabilities (using loop ...
0
votes
1
answer
53
views
Pytorch log normalisation calculation
I do not understand how Pytorch does Log normalisation and searching around I can not find a good example/explanation. Can someone provide an explanation please?
eg
input_tensor =torch.tensor([0.6,0.4]...
0
votes
1
answer
32
views
How to deal with off-by-one issues in convolution (Python)?
I'm trying to write a function to add two random varibles X1 and X2. In my case, they are both uniform random variables from 0 to a1 and 0 to a2. To compute the random variable Y = X1 + X2, I need to ...
2
votes
0
answers
21
views
Probability 0 in Importance Sampling
I have a general question about the methods that use importance sampling in RL. What happens when the probability of either one of the policies is 0?
0
votes
1
answer
105
views
Normalize list of floats to probabilities
I have a list of probability weights like weights = [3, 7, 4, 2] and I want to normalize it so that sum(weights) == 1.
This can be later used for something like "A weighted version of random....
-2
votes
0
answers
30
views
IPD from Kaplan Meir! Pls help this rookie out
I've spent the past two days trying to first, understand R from scratch and second, get this code to run.
I got this code initially from a paper https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3313891/#...
1
vote
1
answer
27
views
Why does integrating scipy.multivariate_normal give incorrect probability?
I'm trying to integrate an independent bivariate normal distribution over a square region. The numerical integration does not match a Monte Carlo simulation. What's going wrong here?
import numpy as ...
0
votes
0
answers
31
views
Random selection based on weightage and previous history
I have a spring boot application for a notification system. Consider sms notifications for which I have n vendors to select from. Every vendor has been promised a certain percentage of our business, ...
0
votes
1
answer
53
views
R: repeat experiment for 1000 times, saving variable in every repeat
I have simulation in which i create 2 groups of 100 patients in each group. Dataframe contain patients, type of intervention (R for reference and T for test) and recovery status (1 or 0). Then I need ...
1
vote
0
answers
16
views
T-distribution, to use or to not use
The question is asking to find if probability of having average low or low as 18?
I have mu = 20, n = 25, X bar = 18, and std dev = 2
Since I do not have variance, I assume I am supposed to use t-...
0
votes
1
answer
46
views
Does a package or command exists in R programming language that directly calculates the Probability integral transform (PIT) directly?
I have four sets of random data samples generated by four dependent random variables. I want to apply copula fitting onto it. For this, I need to find Probability integral transform (PIT). One way is ...
0
votes
0
answers
17
views
How do I calculate posterior probabilities from the results of linear discriminant analysis in Accord.NET?
I am currently porting an image processing project from R to C#. At the end of the pipeline there is a binary classifier for which I have used linear discriminant analysis as the input vector consists ...
0
votes
0
answers
36
views
How to add mutation probability to the NSGA-II code from Pymoo?
My code is Pymoo: Multi-Objective Optimization in Python (NSGA-II).
The mutation is a polynomial mutation (PM).
The code doesn't involve mutation probability, as shown below:
class NSGA2(...
0
votes
0
answers
30
views
Basien network with pomegranate
TypeError Traceback (most recent call last)
----> result = model.predict_proba({'b': None},evidence)
TypeError: BayesianNetwork.predict_proba() takes 2 positional ...
9
votes
2
answers
440
views
Student's t-distribution CDF R base documentation
In the context of the Student's t-distribution cumulative distribution function, R Version 4.3.1's ?dt documentation highlights the following result:
However, upon attempting to verify the accuracy ...
0
votes
1
answer
141
views
How to calculate the probability of drawing at least a specific number of cards from given group(s) of cards?
Here's the deal, I cant find a way to put in code the calculations needed to calculate the probability of
Drawing x cards from group A
And y cards from group B simultaneously
From a deck of cards ...
0
votes
1
answer
19
views
TF1 from TF2 How to get the probability of the model?
Hi I have the following model generated and I have successfully convert the TF 1 example o TF 2 using the Tf migration script.
Here is the model:
tf.compat.v1.reset_default_graph
X = tf.compat....
1
vote
0
answers
94
views
Custom Y-Axis Scaling
I'd like to create a probability plot using matplotlib which has the same scaling as the following plot.
This one imports 'probscale'. However, in the environment I want to deploy the plot probscale ...
1
vote
0
answers
41
views
Issue regarding Triangular Distribution Function calculation
The daily demand for gasoline in a metropolitan area is best modeled according to the Triangular distribution between 1.25 million and 2.05 million gallons, and with a peak (mode) of 1.85 million ...
0
votes
0
answers
24
views
Logic Behind Calculating Probability Using CDF
In the book, Probability and Statistics for Engineers 9th Edition, the following CDF is provided along with two exercises and their solutions:
I understand the logic behind (a), however, what is the ...
0
votes
1
answer
37
views
Computing overall probabilities from a point in a histogram
I have some data: norm = the actual price and norm2 = estimated price. The actual price is something somebody is offering to sell an item for. I ran a Monte Carlo simulation to come up with say 100 ...
0
votes
1
answer
94
views
How to generate uniform random numbers in Python close to the true mean and standard deviation? [closed]
I am trying to generate uniform random numbers as much as possible close to its theoretical definition, particularly in Python. (i.e., I am familiar with the concept of Pesudo-Random Generators (PRGs) ...
0
votes
1
answer
45
views
Python log probability summation code returns astronomically small number [duplicate]
I have the below code:
import numpy as np
def sum_log_prob(l):
# p = l[-1]
# i = len(l) - 1
# while i:
# i -= 1
# curr_p = l[i]
# if p > curr_p:
# p =...
2
votes
3
answers
80
views
PDF for sum of uniform variables in sympy.stats module
The problem statement is the following:
let $X_1$ and $X_2$ be uniformly distributed variables over $(0,1)$ and $(0,2)$, find the pdf representing $Z = X_1 + X_2$. In sympy.stats they only have a ...
0
votes
0
answers
26
views
Tensorflow Probability CDF lower than it's PDF value
I've been testing Tensorflow Probability on some use cases and have some error. Working backwards, I found that, at least in the Normal distribution, you can see that while the PDF value for 0.9568... ...
0
votes
2
answers
36
views
Find four of a kind through simulation in r
There is something off about my function and I am not sure what it is.... any help would be greatly appreciated
#Create a deck of cards
suits <- c("Diamonds", "Clubs", "...
1
vote
1
answer
49
views
Calculating Variance over multiple axes simultaneously
I am trying to understand how varaince over multiple axes works and can it be acheived by using individual operations.
Let us we have a input 3d matrix with shape (2,2,3) and we are interested in ...
1
vote
2
answers
54
views
How do I go from logistic regression to ROC curve and analysis?
I have a dataset that looks like this, where "1" represents if a host is infected and "0" represents if a host is uninfected at that specified dose. However, the ROC function needs ...
1
vote
1
answer
35
views
Issue related to Chi-Square Goodness of Fit Test Calculation
I am trying to solve the question mentioned below. Based on my calculation, I am getting 2,239,444.68 as Chi-Square value and Degree of Freedom as 5. Based on the Chi-Square Calculator, I am getting P-...
0
votes
3
answers
67
views
How to find sample space (all possible outcomes), if coin is tossed n times
Let a list: lst=["head","tail"]
The sample space, if coin tossed 2 times will be:
["H","H"]
["H","T"]
["T","H"]
["T&...