Menu
News
All News
Dungeons & Dragons
Level Up: Advanced 5th Edition
Pathfinder
Starfinder
Warhammer
2d20 System
Year Zero Engine
Industry News
Reviews
Dragon Reflections
White Dwarf Reflections
Columns
Weekly Digests
Weekly News Digest
Freebies, Sales & Bundles
RPG Print News
RPG Crowdfunding News
Game Content
ENterplanetary DimENsions
Mythological Figures
Opinion
Worlds of Design
Peregrine's Nest
RPG Evolution
Other Columns
From the Freelancing Frontline
Monster ENcyclopedia
WotC/TSR Alumni Look Back
4 Hours w/RSD (Ryan Dancey)
The Road to 3E (Jonathan Tweet)
Greenwood's Realms (Ed Greenwood)
Drawmij's TSR (Jim Ward)
Community
Forums & Topics
Forum List
Latest Posts
Forum list
*Dungeons & Dragons
Level Up: Advanced 5th Edition
D&D Older Editions, OSR, & D&D Variants
*TTRPGs General
*Pathfinder & Starfinder
EN Publishing
*Geek Talk & Media
Search forums
Chat/Discord
Resources
Wiki
Pages
Latest activity
Media
New media
New comments
Search media
Downloads
Latest reviews
Search resources
EN Publishing
Store
EN5ider
Adventures in ZEITGEIST
Awfully Cheerful Engine
What's OLD is NEW
Judge Dredd & The Worlds Of 2000AD
War of the Burning Sky
Level Up: Advanced 5E
Events & Releases
Upcoming Events
Private Events
Featured Events
Socials!
EN Publishing
Twitter
BlueSky
Facebook
Instagram
EN World
BlueSky
YouTube
Facebook
Twitter
Twitch
Podcast
Features
Top 5 RPGs Compiled Charts 2004-Present
Adventure Game Industry Market Research Summary (RPGs) V1.0
Ryan Dancey: Acquiring TSR
Q&A With Gary Gygax
D&D Rules FAQs
TSR, WotC, & Paizo: A Comparative History
D&D Pronunciation Guide
Million Dollar TTRPG Kickstarters
Tabletop RPG Podcast Hall of Fame
Eric Noah's Unofficial D&D 3rd Edition News
D&D in the Mainstream
D&D & RPG History
About Morrus
Log in
Register
What's new
Search
Search
Search titles only
By:
Forums & Topics
Forum List
Latest Posts
Forum list
*Dungeons & Dragons
Level Up: Advanced 5th Edition
D&D Older Editions, OSR, & D&D Variants
*TTRPGs General
*Pathfinder & Starfinder
EN Publishing
*Geek Talk & Media
Search forums
Chat/Discord
Menu
Log in
Register
Install the app
Install
Upgrade your account to a Community Supporter account and remove most of the site ads.
Enchanted Trinkets Complete--a hardcover book containing over 500 magic items for your D&D games!
Community
General Tabletop Discussion
*Pathfinder & Starfinder
It's a Wand! It's a Crossbow Bolt! It's a Floor Wax!
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="babomb" data-source="post: 2634409" data-attributes="member: 1316"><p>I can give you the C++ code I used to figure it out. Will that help?</p><p></p><p>[code]</p><p>#include <cmath></p><p>#include <cstdlib></p><p>#include <iostream></p><p></p><p>using namespace std;</p><p></p><p>const int DIE_TYPE = 10;</p><p>const double PROB_NOT_ONE = (double)(DIE_TYPE-1)/DIE_TYPE;</p><p>const double PROB_ONE = 1/(double)DIE_TYPE;</p><p>const double CUTOFF_PROB = 0.50;</p><p></p><p>int main()</p><p>{</p><p> double cum_prob = 0;</p><p> double cum_prob_not_one = 1;</p><p> double prob = 0;</p><p> double last_cum_prob = 0;</p><p> int i = 0;</p><p> double median = 0;</p><p> </p><p> cout << "d" << DIE_TYPE << endl;</p><p> </p><p> for(; cum_prob < CUTOFF_PROB; ++i)</p><p> {</p><p></p><p> prob = cum_prob_not_one * PROB_ONE;</p><p> last_cum_prob = cum_prob;</p><p> cum_prob += prob;</p><p> </p><p> cout << i + 1 << ": " << cum_prob << endl;</p><p> </p><p> cum_prob_not_one *= PROB_NOT_ONE;</p><p> }</p><p> </p><p> median = (0.50 - last_cum_prob)/(cum_prob - last_cum_prob) + i - 1;</p><p> cout << "median: " << median <<endl;</p><p> </p><p> system("PAUSE");</p><p> return 0;</p><p>}</p><p>[/code]</p><p></p><p>The output it gives me is</p><p>[code]</p><p>d10</p><p>1: 0.1</p><p>2: 0.19</p><p>3: 0.271</p><p>4: 0.3439</p><p>5: 0.40951</p><p>6: 0.468559</p><p>7: 0.521703</p><p>median: 6.59162</p><p>Press any key to continue . . .[/code]</p><p></p><p>If you don't understand C++, here's the math class version:</p><p>First, find the cumulative probability that a one is rolled. You can stop when you get a cumulative probability of greater than 50%.</p><p>The cumulative probability for the nth roll is as follows:</p><p>c<img src="https://cdn.jsdelivr.net/joypixels/assets/8.0/png/unicode/64/1f44e.png" class="smilie smilie--emoji" loading="lazy" width="64" height="64" alt="(n)" title="Thumbs down (n)" data-smilie="23"data-shortname="(n)" /> = p(1), n = 1</p><p> = p(not 1)^(n-1) * p(1) + c(n-1), n > 1</p><p></p><p>I'll use m for the lowest roll with a cumulative property <=.5. For the d10, m=6.</p><p>Now find the following:</p><p>A = c(m); For a d10, that's 0.468559 (the 6th roll).</p><p>B = c(m+1); For a d10, that's 0.521703 (the 7th roll).</p><p>deltac = .5 - A; For the d10, that's .031441</p><p>I = the distance between intervals. This is 1 for any die, but if we could find the cumulative probability at half-rolls, we could use 1/2.</p><p>R = B-A; For a d10, 0.053144.</p><p>deltax = deltac * I/R; For a d10, that's .59162.</p><p>median = m + deltax; in this case, 6.59162</p><p></p><p>If geometry helps, you plot the points (m, c(m)) and (m+1, c(m+1)). Then draw a line between them. Find the slope of that line (R/I). Since you know a point on the line (namely, (m, c(m)), you can write the equation of the line as</p><p> c - c(m) = (R/I) * (median-m)</p><p>.5 - A = R/I * (median - m); c = .5, A = c(m) (as above)</p><p>deltac = R/I * (median - m); deltac = .5 - A (as above)</p><p>deltac * I/R = median - m</p><p>deltac * I/R + m = median</p><p>deltax + m = median; deltax = deltac * I/R</p><p>QED.</p></blockquote><p></p>
[QUOTE="babomb, post: 2634409, member: 1316"] I can give you the C++ code I used to figure it out. Will that help? [code] #include <cmath> #include <cstdlib> #include <iostream> using namespace std; const int DIE_TYPE = 10; const double PROB_NOT_ONE = (double)(DIE_TYPE-1)/DIE_TYPE; const double PROB_ONE = 1/(double)DIE_TYPE; const double CUTOFF_PROB = 0.50; int main() { double cum_prob = 0; double cum_prob_not_one = 1; double prob = 0; double last_cum_prob = 0; int i = 0; double median = 0; cout << "d" << DIE_TYPE << endl; for(; cum_prob < CUTOFF_PROB; ++i) { prob = cum_prob_not_one * PROB_ONE; last_cum_prob = cum_prob; cum_prob += prob; cout << i + 1 << ": " << cum_prob << endl; cum_prob_not_one *= PROB_NOT_ONE; } median = (0.50 - last_cum_prob)/(cum_prob - last_cum_prob) + i - 1; cout << "median: " << median <<endl; system("PAUSE"); return 0; } [/code] The output it gives me is [code] d10 1: 0.1 2: 0.19 3: 0.271 4: 0.3439 5: 0.40951 6: 0.468559 7: 0.521703 median: 6.59162 Press any key to continue . . .[/code] If you don't understand C++, here's the math class version: First, find the cumulative probability that a one is rolled. You can stop when you get a cumulative probability of greater than 50%. The cumulative probability for the nth roll is as follows: c(n) = p(1), n = 1 = p(not 1)^(n-1) * p(1) + c(n-1), n > 1 I'll use m for the lowest roll with a cumulative property <=.5. For the d10, m=6. Now find the following: A = c(m); For a d10, that's 0.468559 (the 6th roll). B = c(m+1); For a d10, that's 0.521703 (the 7th roll). deltac = .5 - A; For the d10, that's .031441 I = the distance between intervals. This is 1 for any die, but if we could find the cumulative probability at half-rolls, we could use 1/2. R = B-A; For a d10, 0.053144. deltax = deltac * I/R; For a d10, that's .59162. median = m + deltax; in this case, 6.59162 If geometry helps, you plot the points (m, c(m)) and (m+1, c(m+1)). Then draw a line between them. Find the slope of that line (R/I). Since you know a point on the line (namely, (m, c(m)), you can write the equation of the line as c - c(m) = (R/I) * (median-m) .5 - A = R/I * (median - m); c = .5, A = c(m) (as above) deltac = R/I * (median - m); deltac = .5 - A (as above) deltac * I/R = median - m deltac * I/R + m = median deltax + m = median; deltax = deltac * I/R QED. [/QUOTE]
Insert quotes…
Verification
Post reply
Community
General Tabletop Discussion
*Pathfinder & Starfinder
It's a Wand! It's a Crossbow Bolt! It's a Floor Wax!
Top