Multimodal distribution in NetLogo - netlogo

I wish to distribute turtles according to Multimodal distribution(positive and negative) in netlogo. The turtles should be distributed along positive and negative but only along negative y axis. But NetLogo seems to provide no methods for doing this like random-normal or random-poission.

Depends on the type of multimodal distribution you want. Multimodal just means there is more than one peak in the density curve. Just add together multiple distributions or choose between multiple distributions. The only thing you need to be careful about is that total probability remains 1. Here's one option that will give you a mode at +1 and another at -1 with equal variance around the two.
[ set num ifelse-value (random-float 1 < 0.5)
[ random-normal -1 0.2 ]
[ random-normal 1 0.2 ]
]

Related

How Orange3 gets cosine value in Distances widget

Orange3 says that cosine of No.1 vector[1, 0] to No.2 vector[0, 1] is 1.000 and No.1 to No.7 vector[-1, 0] is 2.000 in Distance Matrix as below capture. I believe that it has to be 0.000 and -1.000 because it is supposed to be cosine. Or if it is radian, it has to be 1.5708(pi/2) and 3.1415(pi).
Sounds like range of cosine is 0.0 to 2.0 in Orange3, but I've never told this before.
Does someone have any idea of this cosine results?
Thank you.
What you describe is cosine similarity. Orange computes cosine distance.
The code is here: https://github.com/biolab/orange3/blob/master/Orange/distance/distance.py#L455.

Is there a way to code a multivariate normal distribution in NetLogo

I want to sample from a multivariate normal distribution for a model in netlogo. I know there's a random-normal function but I'd like to extend this to two dimensions.
Or am I better off coding it up in R and feeding it to the netlogo model that way?
Okay, it's been a long time since I had to do something like this. But you want something like (with rho as your correlation that you control):
set dim1 random-normal 1 0.2
set dim2 rho * dim1 + sqrt(1 - rho ^ 2) * random-normal 5 1
You might want to check on crossvalidated (the statistics equivalent to stackoverflow) to get the correct formula. But it's definitely straightforward to do in NetLogo once you know how to adjust a normal random number to introduce the dependency. Using the R extension is always fiddly and it's not worth the effort if this is all you are doing with it.

How to get a number of probability distributions "averaged"?

Let us say I have 'n' vectors of data of unequal lengths. All of these vectors are similar (range, etc., see example below), and can be fitted into a specific probability distribution. How can we average out these distributions? Does it make sense? If yes, how do I go about programming it ?
For example:-
for n=2, for data1 of 400 samples, I get normal distribution with range 1 to 5, and mean 3 and standard deviation 0.75.
for data2 of 500 samples, I get normal distribution with range 0.95 to 5.2, and mean 3.05 and standard deviation 0.78.

Using Vectors in NetLogo

How can you define add or subtract vectors in NetLogo. It doesn't seem to have any datatype pertaining to it.
By vectors I here am talking in terms specifically velocity of a turtle.
Are there any extensions in netlogo that support this, I can't find any.
I don't know of an extension that provides vectors. But the math involved to code it in NetLogo itself is generally not that complicated. So for example suppose you choose to represent a two-dimensional vector as a list of two numbers. Then:
to-report vector-add [v1 v2]
report (list (first v1 + first v2) (last v1 + last v2))
end
observer> show vector-add [0.1 0.2] [0.5 0.3]
observer: [0.6 0.5]
vector-add can also be written as:
to-report vector-add [v1 v2]
report (map + v1 v2)
end
which works on vectors of any dimension.

Is there a correct way of taking a histogram of ratios?

My problem is as follows; I have two vectors u and v. I have computed a table of cross-ratios like so:
[ u1/v1, u1/v2, u1/v3, u1/v4, ... ]
[ u2/v1, u2/v2, u1/v3, u2/v4, ... ]
[ u3/v1, u3/v2, u1/v3, u3/v4, ... ]
[ u4/v1, u4/v2, u1/v3, u4/v4, ... ]
[ ...
My task now is to compute a histogram of these cross ratios. However, it is clear that using linear histogram bins would not make sense - any ratios below 1 would have a far lower sample resolution than the ratios above 1, and the long-tailed nature of the ratio distribution means that my choice of bins would be skewed heavily by large values.
So, my question is: is there a 'correct', or at least better, choice of histogram bins (or equivalently, a transformation to apply to the data) for this situation? I can see that the Cauchy distribution might be relevant although I'm quite sure how.
Many thanks in advance.
Try plotting the histogram of the log of the ratios. This works as long as your values are strictly positive, and has the nice property that log(u1/v1) = -log(v1/u1).
You may calibrate the histogram's bins manually using histc.