Help - Search - Members - Calendar
Full Version: Matrix math
Dumpshock Forums > Discussion > Shadowrun
Pages: 1, 2
Sengir
I'm currently trying to calculate the probabilities of successfully hacking a node on the fly, in other words beating the Firewall threshold AND not raising an alarm.

But with the "I roll once, node rolls once" mechanic things get a little more complicated than a simple threshold roll (or maybe I'm too stupid to find an easy formula), so here's the best I came up with:

FW = Node's Firewall
ST = Hacker's Stealth


P(succeeding on the n-th roll) = P(hacker accumulated >=FW hits on the n-th roll) * P(node accumulated <ST hits on the n-th roll) * P(hacker accumulated <FW hits on the n-1-th roll)

P(having accumulated >=X hits on the n-th roll) is trivial, just sum up the dice rolled on tests 1 to n and look at the CDF. Total chance of the hacker succeeding is the sum for n=1 to n=(attacker's DP), assuming you use the "-1 dice on each successive test" rule.

------

Am I getting somewhere, or should I just go back to reading probability theory for dummies?
NiL_FisK_Urd
In excel you calculate it using the "BINOMDIST" function, eg. to get 5 or more Hits with 4 dice on turn #1 etc.

=1-BINOMDIST(4;TURN*4;1/3;1) [Calculate 100% minus the chance to get 0-4 hits]

BINOMDIST(X;Y;Z;M)
X = Number of Hits needed -1
Y = Dice rolled (TURN*DICEPOOL or if you use degrading dicepools the sum of all dice on turn #)
Z = Chance to get a hit with one die (1/3)
M = Not Cumulated/Cumulated (0/1) -> set to 1

How to calculate both things in one is not that easy ...
_Pax._
QUOTE (Sengir @ Dec 2 2012, 04:22 PM) *
FW = Node's Firewall
ST = Hacker's Stealth

Don't forget that the Node gets FW+Analyze for it's die pool to detect the hacker.
Iduno
If you're using excel, couldn't you calculate the chances of the player getting in each round in one column, and the chances of getting caught in a second column?

I think the chance of getting in without getting caught would be something like (chance of getting in)*(1 - chance of getting caught), but I signed up for statistics on 2 hours of sleep and ended up in statics.
Sengir
QUOTE (Iduno @ Dec 3 2012, 04:34 PM) *
If you're using excel, couldn't you calculate the chances of the player getting in each round in one column, and the chances of getting caught in a second column?

I got access to a Matlab license, so stuff like "sum from 1 to n" is relatively easy. The question is just whether I'm conceptually on the right track...

QUOTE
I think the chance of getting in without getting caught would be something like (chance of getting in)*(1 - chance of getting caught), but I signed up for statistics on 2 hours of sleep and ended up in statics.

Problem is that the chance of getting caught depends on how many attempts you need to get in, hence the whole act of breaking it down into what happens on the n-th roll


For those interested, here is my ML code so far (nothing fancy, hence it should run on free alternatives like FreeMat or Octave)
CODE
function probability=matrix_stochastics(dicepool_att,firewall,dicepool_def,stealth)

    probability = 0;

    for i = 1:dicepool_att
        
        temp=extendedtest(dicepool_att, firewall, i)*(1-extendedtest(dicepool_def, stealth, i))...
            * (1-extendedtest(dicepool_att, firewall, i-1));
        %numbers go too small?
        if ~isnan(temp)
            probability = probability + temp;
        else
            break;
        end
            
    end

end


function probability=extendedtest(dicepool, threshold, max_attempts)

    if max_attempts > 0
        total_dice = sum(dicepool-max_attempts+1 : dicepool);

        probability = (1-binocdf(threshold-1,total_dice,1/3));
    else
        probability = 0;
    end
    
end
Iduno
QUOTE (Sengir @ Dec 3 2012, 12:07 PM) *
I got access to a Matlab license, so stuff like "sum from 1 to n" is relatively easy. The question is just whether I'm conceptually on the right track...


Problem is that the chance of getting caught depends on how many attempts you need to get in, hence the whole act of breaking it down into what happens on the n-th roll


Ah Matlab, so using a separate row for each round won't work so well. I did have a math professor trying to teach us how to use it, but he was the only one with a copy. Are the free Matlab alternatives any good, or are they as hopelessly gimped as excel alternatives/excel home version (they took out the data analysis tools out of excel home - like taking punctuation out of word)?
Murray
QUOTE (Iduno @ Dec 3 2012, 05:56 PM) *
Ah Matlab, so using a separate row for each round won't work so well. I did have a math professor trying to teach us how to use it, but he was the only one with a copy. Are the free Matlab alternatives any good, or are they as hopelessly gimped as excel alternatives/excel home version (they took out the data analysis tools out of excel home - like taking punctuation out of word)?


You can use GNU Octave (Heres the sorceforge site: http://octave.sourceforge.net/ ). It's basically a Matlab clone.

And to the authors problem: Do you need just a result? Or do you need an analytical formula? If you only need a result just simulate it and use the "law of great numbers".
Sengir
QUOTE (Murray @ Dec 4 2012, 09:12 AM) *
You can use GNU Octave (Heres the sorceforge site: http://octave.sourceforge.net/ ). It's basically a Matlab clone.

I can only offer second-hand opinions, but those agree that Octave does a good job.

QUOTE
And to the authors problem: Do you need just a result? Or do you need an analytical formula? If you only need a result just simulate it and use the "law of great numbers".

I want to plot the chances of hacking something OTF depending on attacker's and defender's pool size, Firewall, and Stealth ratings (well, not all four in one plot wink.gif). So simulating a sufficient number of trials would probably not be very efficient, plus I know even less about Simulink than Matlab. That's also the reason why I don't simply test my formula in a simulation, the correctness of the simulation itself would be rather questionable...
Lionhearted
Why are you doing this exactly? Seems like an awful lot of work to do just for the sake of it... Asking out of genuine curiosity.
_Pax._
Some people like math, for the sake of math itself. smile.gif
Sengir
QUOTE (Lionhearted @ Dec 4 2012, 05:46 PM) *
Why are you doing this exactly? Seems like an awful lot of work to do just for the sake of it... Asking out of genuine curiosity.

Originally just as an exercise to get started with Matlab, now mostly because
a) I simply want to figure it out
b) there's an idea in my head how R. 2 commlinks would no longer be open books without making that R. 4 camera impossible to hack, and I'm not making a gazillion dice rolls to see if it works wink.gif
Halinn
QUOTE (Lionhearted @ Dec 4 2012, 05:46 PM) *
Why are you doing this exactly? Seems like an awful lot of work to do just for the sake of it... Asking out of genuine curiosity.

Knowing the chances of your hacker getting caught is always nice to know.
Draco18s
QUOTE (_Pax._ @ Dec 4 2012, 01:23 PM) *
Some people like math, for the sake of math itself. smile.gif


Have I mentioned on the forums that I calculated the odds that a character I have in this one game will end up screwing a direct decedent of his?
That is, if he were to have sex, the odds that it would be incest (although it would be very distance incest; equivalent to the fact that you and your significant other are ~200th cousins).

Turns out, it's pretty much guaranteed, due to the number of generations that separate him from his initial offspring point from his current position in the timestream.*
(The % of shared DNA is something like 1 part in 10,000 though).

I wasn't able to model population group separation (e.g. non-decedents isolating themselves), but it's largely irrelevant, as if there was even just one decedent in the original group they didn't know about, or anyone from another group migrating in, the pool would be permanently polluted.

Math is fun.

*55 generations, give or take. After 15, the entire world population would be related (based on a number 100 times bigger than the GM gave me for starting population size). GM's guess was "about two-thirds" which turned out to be low.
Lionhearted
QUOTE (_Pax._ @ Dec 4 2012, 06:23 PM) *
Some people like math, for the sake of math itself. smile.gif

Math is the reason I don't get a science degree, I struggled to get through math in school and I would need to read two more courses to qualify to the basic year of natural science education... I enjoy it when it clicks, but Im just not wired to deal well with numbers...
Tanegar
QUOTE (Iduno @ Dec 3 2012, 10:34 AM) *
I signed up for statistics on 2 hours of sleep and ended up in statics.

What is a statics class?
NiL_FisK_Urd
QUOTE (Lionhearted @ Dec 4 2012, 07:09 PM) *
Math is the reason I don't get a science degree, I struggled to get through math in school and I would need to read two more courses to qualify to the basic year of natural science education... I enjoy it when it clicks, but Im just not wired to deal well with numbers...

When you deal with numbers, it is not called math - it is calculating.
Lionhearted
QUOTE (NiL_FisK_Urd @ Dec 4 2012, 08:10 PM) *
When you deal with numbers, it is not called math - it is calculating.

You do calculating in math, same difference?
Halinn
QUOTE (Draco18s @ Dec 4 2012, 06:58 PM) *
Have I mentioned on the forums that I calculated the odds that a character I have in this one game will end up screwing a direct decedent of his?
That is, if he were to have sex, the odds that it would be incest (although it would be very distance incest; equivalent to the fact that you and your significant other are ~200th cousins).

Turns out, it's pretty much guaranteed, due to the number of generations that separate him from his initial offspring point from his current position in the timestream.*
(The % of shared DNA is something like 1 part in 10,000 though).

I wasn't able to model population group separation (e.g. non-decedents isolating themselves), but it's largely irrelevant, as if there was even just one decedent in the original group they didn't know about, or anyone from another group migrating in, the pool would be permanently polluted.

Math is fun.

*55 generations, give or take. After 15, the entire world population would be related (based on a number 100 times bigger than the GM gave me for starting population size). GM's guess was "about two-thirds" which turned out to be low.

For comparison, Genghis Khan is the predecessor of about 1 in 200 men, and he is from 30 generations ago. Unless the starting population for that was really low, no way are you related to everybody after 15.
Draco18s
QUOTE (Halinn @ Dec 4 2012, 03:51 PM) *
For comparison, Genghis Khan is the predecessor of about 1 in 200 men, and he is from 30 generations ago. Unless the starting population for that was really low, no way are you related to everybody after 15.


It was really low. wink.gif

The GM stated the initial population size of 100, 3 of them mine. But I know that that is unsustainably low (for humans, 250 is the absolute minimum in terms of genetic diversity). I think my largest model peaked at 100,000 initial individuals (3 of them mine). Above that my computer ran out of memory before hitting the 100% saturation threshold.

The higher the initial population, the longer it takes, but even at 100,000, it was taking an average of 14 to 16 generations (at 100 it was fully saturated in something like 8 to 10). This is, of course, assuming completely random mate selection (ignoring direct siblings), which is not true in the real world.

Edit:
Located the simulator.
3 in 100 finishes at 15 generations.
3 in 10,000 finishes at 16 (these take too long to run multiple times, it was at 96% after 15 and a final population size of 880,000)
3 in 100,000 finishes.....this may take a while. nyahnyah.gif Edit 2: Ah, 100k is the one that crashes.
Halinn
Also, now that I look at my source again, that "1 in 200" is only for direct male descendants, which obviously lowers the number by a lot.
Draco18s
QUOTE (Halinn @ Dec 4 2012, 04:52 PM) *
Also, now that I look at my source again, that "1 in 200" is only for direct male descendants, which obviously lowers the number by a lot.


That it does, heh. I could have modeled something like that, but I didn't. Mainly because my character is male, and he'd be knocking up the girls. nyahnyah.gif
(And there's a reason why he's called "The Defiler." ;D )
Lionhearted
QUOTE (Halinn @ Dec 4 2012, 09:52 PM) *
Also, now that I look at my source again, that "1 in 200" is only for direct male descendants, which obviously lowers the number by a lot.

Believe that has something to do with genetic markers that are only passed down from male to male, similarly you can do the same for women to find the last common ancestor.
Halinn
QUOTE (Draco18s @ Dec 4 2012, 10:11 PM) *
That it does, heh. I could have modeled something like that, but I didn't. Mainly because my character is male, and he'd be knocking up the girls. nyahnyah.gif
(And there's a reason why he's called "The Defiler." ;D )

That'd actually be a reason for modeling it. Check how many of your offspring were male, then how many of those males were male and so on.
Draco18s
QUOTE (Halinn @ Dec 4 2012, 05:31 PM) *
That'd actually be a reason for modeling it. Check how many of your offspring were male, then how many of those males were male and so on.


Oh, I modeled gender I just didn't model direct dependency (male -> male separately from female -> male).
Ryu
QUOTE (Sengir @ Dec 3 2012, 05:07 PM) *
I got access to a Matlab license, so stuff like "sum from 1 to n" is relatively easy. The question is just whether I'm conceptually on the right track...

Canīt help you with Mathlab (dabbled for a while, but a decade ago).

P(succeeding on the n-th roll) = P(hacker accumulated >=FW hits on the n-th roll) * P(node accumulated <ST hits on the n-th roll) * P(hacker accumulated <FW hits on the n-1-th roll)

Hacking on the Fly is an extended opposed test. Under your conditions:

1st turn
P(attacker win (1 turn)*(1- P(defender win (1 turn))

2nd turn
[1-P(attacker win (1 turn)*(1- P(defender win (1 turn))] * P(attacker win (2 turns)*(1- P(defender win (2 turns))

And so on. Should be over after 4 turns in most situations, but your math will likely not care for total turns wink.gif

For a given players stats, a matrix of odds (stealth vs target dp) could be VERY cool: Firewall 3-8, target dp 6-16. Please? *ducks*

Sengir
QUOTE (Ryu @ Dec 5 2012, 12:00 AM) *
2nd turn
[1-P(attacker win (1 turn)*(1- P(defender win (1 turn))] * P(attacker win (2 turns)*(1- P(defender win (2 turns))

Hmm, doesn't (1- P(defender win (2 turns)) already include the defender having failed at T1?
Ryu
Iīm going for (Probability of a first turn win) + [Probability of results that allow a second turn] * (Probability of 2nd turn win).

So the chance of being detected has to be used for calculation in both turn 1 and 2. Huh, I think. Does someone else have an idea or corrections?
Sengir
Well, I just managed to figure out one thing, my way of calculating extended tests is BS:

By my math, the chance to roll one die twice and score a hit on the second attempt is P(0 hits with one die) * P(>= 1 hits with two dice). But that also includes the impossible event "roll 0 hits on the first try and a total of two hits on two rolls". Back to the drawing board, stupid...
Tanegar
I still want to know what one learns in a "statics" class.
Ryu
I assume you learn about the physics of unmoving objects. So you can later advance into the "happy" math of dynamics.
Sengir
Got fed up with thinking about formulas and picked up on Murray's advice again: Just simulate the damn thing with enough iterations. Matlab code for those interested, it should be readable if you know a bit about any programming language (and no, Matlab does not have ++ or += operators):
[ Spoiler ]



As an example output I present the chance of hacking a Security account at a R. 3 node running Analyze 3, as function of the attacker's DP and Stealth rating:
http://postimage.org/image/atkk35isx/full/ (better image host now)
Tymeaus Jalynsfein
Awesome Sengir, Thanks. smile.gif
thorya
QUOTE (Tanegar @ Dec 5 2012, 07:21 PM) *
I still want to know what one learns in a "statics" class.


I use to be a TA for this class. It's an engineering class that focuses upon forces and moments (torques for lay people) of stationary structures or situations. Things like the wind loading on a billboard, a roof supporting weight from snow or other distributed loads based upon its design, etc. It's usually a end of first year or beginning of second year course for mechanical and civil engineers. Hope that helps.

P.S. sorry, it's not about static electricity or anything cool like that.
_Pax._
QUOTE (Sengir @ Dec 6 2012, 07:47 AM) *
As an example output I present the chance of hacking a Security account at a R. 3 node running Analyze 3, as function of the attacker's DP and Stealth rating:
http://postimage.org/image/atkk35isx/full/ (better image host now)

That's very interesting. I hadn't thought yoru Stealth program had more to do with your chance o success, than your die pool.

Is that "regardless of number of rolls needed", or what?
Tymeaus Jalynsfein
QUOTE (_Pax._ @ Dec 6 2012, 11:55 AM) *
That's very interesting. I hadn't thought yoru Stealth program had more to do with your chance o success, than your die pool.

Is that "regardless of number of rolls needed", or what?


Well, I imagine the Numbers change when performing a Slow Hack. IIRC, the initial query was based upon a Hack-on-the-Fly Attempt.
Eratosthenes
So a hacker with Stealth 6 and a 14-16 DP vs. a Rating 3 node with Analyze 3 (DP 6) has ~10% chance of being detected when hacking-on-the-fly?
NiL_FisK_Urd
It would be interesting how this graph scales when considering that a starting technomancer could get stealth up to 12.
Sengir
QUOTE (Eratosthenes @ Dec 6 2012, 09:02 PM) *
So a hacker with Stealth 6 and a 14-16 DP vs. a Rating 3 node with Analyze 3 (DP 6) has ~10% chance of being detected when hacking-on-the-fly?

For a Security account, mind you.

Another interesting observation: If you do not apply the cumulative -1 to the node's DP, the result looks like this. A remarkably small difference (at least far smaller than I expected) for hackers rolling twelve or more dice.

More graphs for various Ratings and account levels (User/Security/Admin) by tomorrow, I'll hit the bed now.
UmaroVI
Probably the simplest way to do it directly - ie, deriving the actual probability rather than approximating it with an experiment - would be to use the negative binomial distribution. Negative binomials give you the distribution of the number of total dice rolled before you have X successes. If you have a dicepool of d, then the sum of the negative binomial distribution from (s-1)d+1 to sd gives you the probability that you get to X successes after precisely s tests (without the -1 per cumulative test), or from (s-1)d-(s-1)s/2+1 to (s-1)d-(s-1)s/2+1+d-s if you are using the -1 per cumulative test (with the remaining probability meaning you never reach it). At this point you have a probability distribution (albeit a mildly ugly one) for the probability of taking exactly s tries to get to X successes, so you can do a simple conditional probability summation to get to your answer.

This does, however, ignore glitches which do make things a bit of a nuisance to calculate.

Sengir
As promised, lots of colorful lines:

Tymeaus Jalynsfein
Which pretty much proves that the Hacker in a Box (rolling 6 Dice) hacking Rating 2 Comlinks in the Quad for 5 nuyen.gif each will rarely, if ever, really succeed at its mission. Thanks Sengir. Pretty much what I expected. smile.gif
Sengir
QUOTE (Tymeaus Jalynsfein @ Dec 7 2012, 03:56 PM) *
Which pretty much proves that the Hacker in a Box hacking Rating 2 Comlinks in the Quad for 5 nuyen.gif each will rarely, if ever, really succeed at its mission. Thanks Sengir. Pretty much what I expected. smile.gif

Depends...if you want to use it as a banking trojan (I assume you were referring to that discussion) it would very rarely succeed, since that requires Admin access. On the other hand, getting User access to to read somebody's stuff will succeed in ~75% of all cases, so a R. 2 commlink is pretty much an open book.
Tymeaus Jalynsfein
QUOTE (Sengir @ Dec 7 2012, 12:21 PM) *
Depends...if you want to use it as a banking trojan (I assume you were referring to that discussion) it would very rarely succeed, since that requires Admin access. On the other hand, getting User access to to read somebody's stuff will succeed in ~75% of all cases, so a R. 2 commlink is pretty much an open book.


Talking about the Trojan for banking that money.
And from your graph, 6 dice vs. 6 Dice is not 75% (since you used a Target Rating 3 Device)... or did I read that wrong? Looks like just above 30% to me.
Iduno
QUOTE (Tanegar @ Dec 4 2012, 02:17 PM) *
What is a statics class?


Sorry, I've been out for a few days. It's about torque, forces, and trigonometry. Significantly different than the probability stuff I expected.
Sengir
QUOTE (Tymeaus Jalynsfein @ Dec 7 2012, 08:23 PM) *
Talking about the Trojan for banking that money.
And from your graph, 6 dice vs. 6 Dice is not 75% (since you used a Target Rating 3 Device)... or did I read that wrong? Looks like just above 30% to me.

For Rating 3 you are reading correctly, but you were talking about "hacking Rating 2 Comlinks in the Quad" wink.gif

Btw, thanks for weighting in Umaro, although I'm happy with the results I have.
Tymeaus Jalynsfein
QUOTE (Sengir @ Dec 7 2012, 12:48 PM) *
For Rating 3 you are reading correctly, but you were talking about "hacking Rating 2 Comlinks in the Quad" wink.gif

Btw, thanks for weighting in Umaro, although I'm happy with the results I have.


Good... just wanted to make sure I was reading the chart correctly.
Awesome work.
Halinn
QUOTE (Sengir @ Dec 7 2012, 08:21 PM) *
Depends...if you want to use it as a banking trojan (I assume you were referring to that discussion) it would very rarely succeed, since that requires Admin access. On the other hand, getting User access to to read somebody's stuff will succeed in ~75% of all cases, so a R. 2 commlink is pretty much an open book.

IIRC, one has to get admin accounts on commlinks.
Lantzer
QUOTE (Tanegar @ Dec 4 2012, 07:17 PM) *
What is a statics class?


Basic Nonmoving Engineering - Forces & displacements for objects like beams, trusses, and the like.
Tymeaus Jalynsfein
QUOTE (Halinn @ Dec 7 2012, 04:17 PM) *
IIRC, one has to get admin accounts on commlinks.


Yes, since no other accounts exist on a comlink by default.
Alpha Blue
QUOTE (Tymeaus Jalynsfein @ Dec 8 2012, 12:47 AM) *
Yes, since no other accounts exist on a comlink by default.

What is this so? That's awesome! That solves so much. Can someone give me background on this?
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Dumpshock Forums © 2001-2012