All Questions

Filter by
Sorted by
Tagged with
22 votes
1 answer
15k views

How to simulate bimodal distribution?

I have the following code to generate bimodal distribution but when I graph the histogram. I don't see the 2 modes. I am wondering if there's something wrong with my code. mu1 <- log(1) mu2 &...
Amateur's user avatar
  • 1,257
21 votes
12 answers
21k views

Probability distribution in Python

I have a bunch of keys that each have an unlikeliness variable. I want to randomly choose one of these keys, yet I want it to be more unlikely for unlikely (key, values) to be chosen than a less ...
10 votes
4 answers
9k views

Generate Random Numbers with Probabilistic Distribution

Ok, so here's my problem. We are looking at purchasing a data set from a company to augment our existing data set. For the purposes of this question, let's say that this data set ranks places with ...
ircmaxell's user avatar
  • 164k
10 votes
4 answers
31k views

Using the gaussian probability density function in C++

First, is this the correct C++ representation of the pdf gaussian function ? float pdf_gaussian = ( 1 / ( s * sqrt(2*M_PI) ) ) * exp( -0.5 * pow( (x-m)/s, 2.0 ) ); Second, does it make sense of we ...
shn's user avatar
  • 5,206
10 votes
3 answers
34k views

Getting Probability Density of Data

I need to analyze some data about internet sessions for a DSL Line. I wanted to have a look at how the session durations are distributed. I figured a simple way to do this would be to begin by making ...
sfactor's user avatar
  • 12.8k
9 votes
3 answers
5k views

Random numbers based on a probability

I'm having trouble generating random numbers that do not follow a discrete uniform distribution. So for example, say I have 5 numbers (to keep it simple), a probability of number k being generated ...
DillPixel's user avatar
  • 955
7 votes
3 answers
5k views

Python, SimPy: How to generate a value from a triangular probability distribution?

I want to run a simulation that uses as parameter a value generated from a triangular probability distribution with lower limit A, mode B and and upper limit C. How can I generate this value in Python?...
andandandand's user avatar
  • 22.1k
7 votes
1 answer
2k views

Why do the inverse t-distributions for small values differ in Matlab and R?

I would like to evaluate the inverse Student's t-distribution function for small values, e.g., 1e-18, in Matlab. The degrees of freedom is 2. Unfortunately, Matlab returns NaN: tinv(1e-18,2) NaN ...
rozsasarpi's user avatar
  • 1,631
6 votes
1 answer
7k views

std normal cdf, normal cdf, or error function

Can any of these functions, the standard normal cumulative distribution function, the normal cumulative distribution function, or the error function, be reliably calculated with javascript? I'd like ...
user avatar
6 votes
2 answers
4k views

Simulate samples from a joint cumulative distribution function?

I have a joint density function for two independent variables X and Y. And I now want to sample new x,y from this distribution. What I believe I have to do is to find the joint cumulative ...
Groot's user avatar
  • 14.1k
6 votes
2 answers
2k views

Sampling from a bounded domain zipf distribution

I'd like to sample from "zipf" distribution from a bounded domain. That is, assume that the domain is {1,...,N}, I'd like each element in the domain, i, to be chosen with probability proportional to ...
R B's user avatar
  • 543
6 votes
2 answers
2k views

C++ - critical values probability distribution

were can I find reliable code for critical values for probability distributions? For instance, F critical values for the fisher test... ? Thanks for any relevant reference.
kiriloff's user avatar
  • 25.9k
6 votes
2 answers
1k views

c++ discrete distribution sampling with frequently changing probabilities

Problem: I need to sample from a discrete distribution constructed of certain weights e.g. {w1,w2,w3,..}, and thus probability distribution {p1,p2,p3,...}, where pi=wi/(w1+w2+...). some of wi's ...
therefore's user avatar
5 votes
1 answer
133 views

Generate random number in range [M....N] with mean X

Generating a random number in the range [M..N] is easy enough. I however would like to generate a series of random numbers in that range with mean X (M < X < N). For example, assume the ...
Ken Adams's user avatar
5 votes
3 answers
12k views

How To Fit Multivariate Normal Distribution To Data In MATLAB?

I'm trying to fit a multivariate normal distribution to data that I collected, in order to take samples from it. I know how to fit a (univariate) normal distribution, using the fitdist function (with ...
Shaked's user avatar
  • 495
5 votes
0 answers
3k views

how to calculate total statistical distance in python

In this link total variation distance between two probability distribution is given. I tried to calculate it in python. I have two datasets and firstly I calculated their probability distribution ...
user3104352's user avatar
  • 1,120
4 votes
1 answer
4k views

Sample from the Erlang distribution in R

The Erlang distribution has two parameters: natural number k (shape parameter) and real number lambda (rate parameter). How can you take a random sample of size n from the Erlang distribution, using R ...
JJJ's user avatar
  • 1,019
4 votes
2 answers
3k views

Different probability for ranges of random numbers

I'm looking for the best way of implementing random number generator, that will allow me to have control over probability from what range the generated number will be returned. To visualize what I'm ...
sasklacz's user avatar
  • 3,618
4 votes
1 answer
545 views

Calculating final market distribution - competitive programming

I came across following question while practicing competitive programming. I solved it manually, kinda designing an approach, but my answer is wrong and I cannot imagine how to scale my approach. ...
Adorn's user avatar
  • 1,401
4 votes
2 answers
760 views

possible distributions and their probabilities after putting identical items into anonymous buckets

Apologies if the answer to this is readily found elsewhere. My math and stats are weak and thus I don't even know the search terms for what I'm trying to do . . . I have b anonymous ...
John Bent's user avatar
  • 133
4 votes
4 answers
3k views

Calculating odds distribution with 6-sided dice

I'm trying to calculate the odds distribution of a changing number of 6-sided die rolls. For example, 3d6 ranges from 3 to 18 as follows: 3:1, 4:3, 5:6, 6:10, 7:15, 8:21, 9:25, 10:27, 11:27, 12:25, ...
Stephen's user avatar
  • 41
4 votes
1 answer
290 views

How to calculated DRPS (Discrete Rank Probability Score)

I am working on replicating the scoring rule found in a paper Forecasting the intermittent demand for slow-moving inventories: A modelling approach The paper describes the scoring rule as follows: ...
Alex's user avatar
  • 2,650
4 votes
2 answers
3k views

Calculate percentiles if we have probability density function data as x and y

I have data extracted from a pdf graph where x represents incubation times and y is the density in a csv file. I would like to calculate the percentiles, such as 95%. I'm a bit confused, should I ...
sakurami's user avatar
  • 339
4 votes
2 answers
5k views

How to draw a random sample from a Poisson distribution?

I have a number X of integers (very large) and a probability p with which I want to draw a sample s (a number) from X following a Poisson distribution. For example, if X = 10^8 and p=0.05, I expect s ...
Joana 's user avatar
  • 49
4 votes
1 answer
2k views

How to calibrate the thresholds of neural network output layer in multiclass classification task?

Assume we have a multi-class classification task with 3 classes: {Cheesecake, Ice Cream, Apple Pie} Given that we have a trained neural network that can classify which of the three desserts a random ...
Mockingbird's user avatar
  • 1,023
3 votes
1 answer
8k views

How to plot CDF in R

I am trying to plot a CDF plot using ecdf() function using the following code: > x<-ecdf(data$V6) > summary(x) Empirical CDF: 2402 unique values with summary Min. 1st Qu. Median ...
Nasir's user avatar
  • 2,032
3 votes
4 answers
2k views

draw random number following a custom distribution [duplicate]

I need to draw random numbers following a distribution I chose. Example: draw 7 numbers from 1 to 7 with those probabilities: 1: 0.3 2: 0.2 3: 0.15 4: 0.15 5: 0.1 6: 0.05 7: 0.05 Since in my ...
Maik Xhani's user avatar
3 votes
3 answers
141 views

rbinom; How to ensure at least one "success" is returned?

Is there a way to ensure rbinom() returns at least one success? I am running rbinom() with a really low probability: rbinom(5015, size=2, prob= 1/5000)) Since it is a probability distribution, there ...
Sky Scraper's user avatar
3 votes
2 answers
2k views

Calculate probability of point on 2d density surface

If I calculate the 2d density surface of two vectors like in this example: library(MASS) a <- rnorm(1000) b <- rnorm(1000, sd=2) f1 <- kde2d(a, b, n = 100) I get the following surface ...
Tim's user avatar
  • 293
3 votes
2 answers
3k views

How to catch warning in Matlab?

I'm using the distfit function of Matlab to fit a probability distribution to my data. Sometimes the following warning message appears: Maximum likelihood estimation did not converge. Iteration ...
machinery's user avatar
  • 6,092
3 votes
3 answers
2k views

Generating a random number with weighted probability - 'Distribution' gem

I would like to create a random number generator, that generates a random decimal number: Greater than 0.0 Less than 15.0 Where the probability of that number being close to 2.0 is relatively high ...
Chris Butcher's user avatar
3 votes
1 answer
714 views

Truncated normal with a given mean

Is it possible in python to generate a truncated normal distribution with a given expected value? I know that scipy.stats.truncnorm can give a truncated normal distribution that takes the mean of the ...
tmldwn's user avatar
  • 465
3 votes
2 answers
2k views

Generating a binomial distribution around zero

I'm looking to generate a binomial-esque distribution. I want a binomial distribution but I want it centred around zero (I know this doesn't make much sense with respect to the definition of binomial ...
jhoyla's user avatar
  • 1,231
3 votes
2 answers
2k views

Converting a Uniform distribution to Poisson distribution

I have to write a C program to convert a uniform distribution of random numbers (say from 0 to 1) to a poisson distribution. Can anyone help?
wiseindy's user avatar
  • 19.6k
3 votes
3 answers
2k views

creating distributions in mathematica

I have a function which I know to be a multivariate distribution in (x,y), and mathematica is having numerical stability issues when I form the marginal distributions. For example, marginalizing ...
casdf's user avatar
  • 31
3 votes
1 answer
690 views

How to programmatically calculate a discrete probabilities

I am using EnumeratedIntegerDistribution to generated samples from my set of keys. How to programmatically calculate a 'discrete probabilities' array. for example I might want an approximate 'normal' ...
dmc's user avatar
  • 401
3 votes
0 answers
332 views

Match dataset distribution to another

I have 2 observed datasets, and I wish to match their distributions according to 2 features. In elaboration - I want to keep one dataset as is, and filter the other according to 2 features's ...
Ofek Finkelstein's user avatar
2 votes
3 answers
8k views

Generating a triangular distribution in Matlab

I have attempted to generate a triangular probability distribution in Matlab, but was not successful. I used the formula at http://en.wikipedia.org/wiki/Triangular_distribution. n = 10000000; a = 0....
Superbest's user avatar
  • 26k
2 votes
3 answers
3k views

SQL Server equivalent of Excel's TINV function

I am trying to find two-tailed inverse of the X's t-distribution. It can be find using TINV function in Excel but I need this to achieve in SQL Sever. Please suggest me idea. The TINV function syntax ...
Vignesh's user avatar
  • 95
2 votes
3 answers
475 views

Storing a probability distribution without saving single values

I am calculating many (~ 100 million) floating point values during an operation. I do not want to store them all in the memory but I want to save a rough distribution of the collection. My idea was ...
RomCoo's user avatar
  • 1,903
2 votes
1 answer
4k views

How to sample from a multinomial distribution?

Lets assume that I have a set of probabilities [0.1, 0.6, 0.2, 0.1]. I want to sample the locations from this set of probabilities. e.g. when I sample I should get the location 1 quite often than ...
user570593's user avatar
  • 3,440
2 votes
1 answer
2k views

Probability distributions and float variables, probability must add to 1

I'm working on a script which goes like this: the program analyses a bunch of text documents in a certain language, draws the probability distributions for each k, where k is the first character ...
mickkk's user avatar
  • 1,182
2 votes
2 answers
447 views

generating sorted random numbers without exponentiation involved?

I am looking for a math equation or algorithm which can generate uniform random numbers in ascending order in the range [0,1] without the help of division operator. i am keen in skipping the division ...
user_rak's user avatar
2 votes
3 answers
679 views

Generate a matrix of transition probabilities for bit strings of given size following some probability distribution

I want to create an 8x8 matrix which provides the error probabilities in bit communication. The matrix looks as follows: The columns amount to the observed quantities and the rows to the measured ...
Marion's user avatar
  • 269
2 votes
2 answers
452 views

Obtain the value of the random variable given the cumulative probability (Python)

Here is a quick background information. I am trying to obtain a combined CDF for the linear combination of two lognormal random variables using Monte-Carlo approach and then, invert it to do sampling. ...
Mechanician's user avatar
2 votes
1 answer
3k views

scipy: How do I use weibull_min.pdf?

I'm finding scipy's weibull_min pdf function unintuitive and hard to use. I want to generate a weibull PDF with scale=30 and shape=2.5. This is what that is supposed to look like: Here's what I've ...
kilojoules's user avatar
  • 10.2k
2 votes
2 answers
224 views

Range for continuos distribution in Julia

I am trying to calculate the density function of a continuos random variable in range in Julia using Distributions, but I am not able to define the range. I used Truncator constructor to construct the ...
Chris Martin's user avatar
2 votes
2 answers
2k views

Algorithm to distribute according to weights, with unknown total of items, guaranteeing good distribution?

I want to distribute tokens into 3 slots. Each slot has some weight: maybe 50% of tokens should go into the first slot, 30% should go into the second slot, 20% into the third slot. I don't know the ...
Henrik N's user avatar
  • 16k
2 votes
2 answers
618 views

R: How to get the p-value (for getting x < 2) for a population (modeled by a combination of three normal distributions)?

Thanks to the wonderful answers to my previous post, I used the procedures provided in the link below, to fit my data with three normal distributions: https://stats.stackexchange.com/questions/10062/...
user2718's user avatar
  • 459
2 votes
1 answer
1k views

Multivariate Normal Distribution fitting dataset

I was reading a few papers about RNN networks. At some point, I came accross the following explanations: The prediction model trained on sN is used to compute the error vectors for each point in the ...
guillaume mendlevitch's user avatar