d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Statistics Help > Poisson, Negative Expo, Normal, Uniform
Add Reply New Topic New Poll
Member
Posts: 14,631
Joined: Sep 14 2006
Gold: 575.56
Mar 8 2017 12:39pm
So, I'm not sure how to do some of the math in a simulation i'm trying to run
Lets say... 100fg per solution except for the 2nd one since i'm pretty sure it's already right

Question: Events occur under poission Distrobution at rate of 3 per hour
what i need is the delta between each event, right now my method just returns 20 minutes (without the distrobution)
Code
//todo implement poission distrobution
private int timeUntilNextArrival() {
//currently just returning 20 minutes but this isnt right
int result = 20*60;
return result;
}


next i need a uniform distribution
i think this one is right but idk
ailments are uniformly distributed HEART: 30% GASTRO: 20% BLEEDER: 50%
Code
//todo implement distrobution
private void setAilment() {
int x = ((int) (Math.random() * 10));
if(x<3)
ailment = Ailment.HEART;
else if(x<5)
ailment = Ailment.BLEED;
else ailment = Ailment.GAS;

}


next is negative exponential distrobution
HEART: 2/HOUR GAS: 4/HOUR BLEED: 6/HOUR
What i need is a delta time in between each event dependent on the ailment again currently i'm just using the given averages without the distrobutioon
Code
private int getTreatmentTime(Ailment ailment){
//todo implement negative exponential distribution
int length=0;
switch (ailment) {
case BLEED:
length = 60 * 60 / 6;
break;
case HEART:
length = 60 * 60 / 2;
break;
case GAS:
length = 60 * 60 / 4;
break;
default:
System.err.println("error in treatment case");
break;
}
return length;
}


Lastly i need a normal distrobution given average and standard deviation
again currently i just use the given average
HEART: AVG:35min STTDV: 10min
GAS: AVG:80min STTDV: 30min
BLEED: AVG:65min STTDV: 20min
Code
//todo implement deviation
private void setDeathTime() {
switch (ailment) {
case BLEED:
deathTime = arrivalTime + 65 * 60;
break;
case GAS:
deathTime = arrivalTime + 80 * 60;
break;
case HEART:
deathTime = arrivalTime + 35 * 60;
break;
default:
System.err.println("case bug in lifetime in waiting line");
break;
}
}


This post was edited by Ideophobe on Mar 8 2017 12:58pm
Member
Posts: 14,631
Joined: Sep 14 2006
Gold: 575.56
Mar 8 2017 07:34pm
theres no rush here i have like 2 more weeks to get this doen, just thought someone on here might have had a bit more math background than i do and be more familiar with coming up with random number generators for distributions

i'll let you know if i come up with anything i guess, havent banged my head against a wall like this in a while

This post was edited by Ideophobe on Mar 8 2017 07:35pm
Member
Posts: 14,631
Joined: Sep 14 2006
Gold: 575.56
Mar 10 2017 03:13pm
got it working with Box Mullers and negative exponential theorems

nvm fun stuff
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll