Message Boards Message Boards


How to scale a binomial distribution by X with error?

Posted 1 month ago
4 Replies
0 Total Likes

I'm trying to simulate a binomial distribution [ n=8, p=0.22]. I want to scale the result by a known weight [e.g., 0.51]. This weight, however, has uncertainty [variance = 0.31] that should be factored in.

Is it possible in Mathematica to randomly scale an outcome by x plus or minus a given variance?

Thanks :)

4 Replies
Posted 1 month ago

Your terminology is not standard ("scale by a known weight") so it's not clear how an outcome might be modified in a probabilistic manner. One specific that needs clarification is "Do the modified outcomes still only consist of the integer values from 0 to 8?"

If so, then one possibility is that one might consider $p$ to be a random variable rather than the constant 0.22. One way to do this is the following:

(* Modify the logit of the probability by adding some noise *)
s = 0.05;
logitp = Log[0.22/(1 - 0.22)] + RandomVariate[NormalDistribution[0, s], 1][[1]]
(* -1.3151 *)

(* Transform back to a probability *)
p = 1 - 1/(1 + Exp[logitp])
(* 0.211634 *)

(* Generate a random observation *)
x = RandomVariate[BinomialDistribution[8, p], 1][[1]]
(* 1 *)

There are lots of other ways, too. Hence, the need for more specifics.

Thank you, Jim.

Apologies for the ambiguous language. I have a measured probability (0.22) of success. The success of each trail corresponds to a particular weight (e.g., measured voltage 0.51 mV). This measurement has error (coefficient of variation + channel noise = 0.31). I am trying to calculate how 8 such units with similar successes and weights would behave (i.e, what is the expected mV and variance).

Here's what I did....
I have treated weight as a random normal variable such that:

weight_SD = RandomVariate[NormalDistribution[0.51,0.31], 100];

pTrials = RandomVariate[BinomialDistribution[8, 0.22], 100];

data = pTrials * weight_SD

Does this seem sound? Thanks again for the help :)

Posted 1 month ago

We speak different terminologies so please take the following comments as my misunderstanding as opposed to a judgement.

Are you wanting to perform a logistic regression where the logit of the probability of success is dependent on a measured voltage plus some additional error?

One possibility is that the logit of the probability of success for a single unit is a linear function of the measured voltage plus some error:

$$\log(p/(1 - p)) = a + b \times voltage + error$$

I'm not following your construction of weights because the example you give will result in about 5% of the weights being negative. (And Mathematica doesn't allow an underscore in a variable name.)

Not to worry - your comments are most helpful and I'm not at all opposed to judgements :)

I suppose I'm trying to do a Monte Carlo where the outcome (mV) is dependent on the probability of success. If, for example, 8 units (in my case presynaptic terminals) release chemical transmitter each with a constant probability (0.22) and the individual (read single unit) response to released transmitter is 0.51 mV with added error (0.31 mV), what is the expected mV response over 100 trials given 8 probabilistically active units (assuming linear summation of voltage).

You are right in that my simple solution resulted in negative voltages. Negative voltages are permissible so long as they do not exceed the absolute value of my error term (which they most certainly do in my failed attempts).

Hope that helps clarifies my objective. Thanks again :)

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract