Quantcast
Channel: Probability in Java (AnyLogic) - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Probability in Java (AnyLogic)

$
0
0

I would like to simulate the probability of producing good products and also defects with let's say 80% probability.

I've seen that it's possible to generate numbers and see if they are equal to the probability I'm looking for. But I'm not that good at Java programming and AnyLogic is a bit different than Java in that I can't call libraries etc I think.

I have tried this but it doesn't work. Only parts_count keeps getting incremented but not parts_defect which stays at 0 during the whole simulation. What am I doing wrong? Thanks

double probability = normal();if ( -2<probability || probability<2){    parts_count += 1;} else if ( -2>probability || probability>2){    parts_defect +=1;}

PS. normal() generates a normal distribution with sigma = 1 and mean = 0. I know 2*sigma is not equal to 80% I was just trying out for the sake of the example.


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>
<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596344.js" async> </script>