Sign in to follow this  
Ogare

Creation success tool and Wurm's normal RNG math.

Recommended Posts

I'm trying to make a tool calculate creation success. I dislike "it depends" answers. It is possible to inform of skill level and tool qualities need to get the 6% creation chance.
 
I'd like help understanding code rollGaussian().
I want to use Python's optimized methods to roll random values from a normal distribution. I can include a mean and standard deviation for the roll. But I don't understand how Wurm is arriving at mean and sigma.
 
Here is the code snip from Skill.rollGaussian()
final float slide = (skill * skill * skill - difficulty * difficulty * difficulty) / 50000.0f + (skill - difficulty);
final float w = 30.0f - Math.abs(skill - difficulty) / 4.0f;
...
result = (float)Skill.random.nextGaussian() * (w + Math.abs(slide) / 6.0f) + slide;

Here I think "slide" is mean. Is this sigma "(w + math.abs(slide) / 6.0f)?

 
I'll include in the simulation that Wurm rolls again values which fall outside the cutoff. Don't worry about this part.

Share this post


Link to post
Share on other sites

This is just a basic liner transformation of a normal variable. To in its general form let X be our random variable where X~N(µ, σ^2), and Y is another random variable where Y = kX + c. Y can be represented as Y~N(kµ+c, k^2*σ^2).

So in this case rollgausian is a standard normal i.e. N(0,1). k is (w+|slide|/6) and c is slide.

 

So our result is Result~N(0*(w+|slide|/6)+slide, (w+|slide|/6)^2*1)

 

Simplified Result~N(slide, (w+|slide|/6)^2)

So your mean is slide and variance is (w+|slide|/6)^2 

And standard deviation (σ) is  (w+|slide|/6)

 

 

I don't know what sigma refers to exactly in the python library you are using but usually it'd be standard deviation.

 

A source for more reading on normal transformations: https://web.stanford.edu/class/archive/cs/cs109/cs109.1178/lectureHandouts/110-normal-distribution.pdf

Edited by Lethyria
Sauced
  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this