g | x | w | all
Bytes Lang Time Link
032TIBASIC TI83 Plus250520T151322Zmadeforl
045Wolfram Language Mathematica220501T045058Zatt
034Charcoal220501T004259ZNeil
116Python 3.8 prerelease220429T085113Zsolid.py
085JavaScript ES6220429T130214ZArnauld
164Bash220429T123240Zmatteo_c
049Burlesque220429T110229ZDeathInc
00805AB1E220429T065650ZKevin Cr

TI-BASIC (TI-83 Plus), 32 bytes

Input G
Input S
Input U
Input L
{0
While G≠sum(Ans
randInt(U,L,S
End
Ans

Can take a while for inputs that have only a few possible outputs, but it works

Wolfram Language (Mathematica), 49 47 45 bytes

RandomChoice@*GroupBy[Range@##2~Tuples~#,Tr]&

Try it online!

Input [SplitCount, LowerLimit, UpperLimit][GrandTotal].

Charcoal, 34 bytes

NθNηNζ≔⊕⁻NζεI‽ΦEXεη⁺﹪÷ιXε…⁰ηεζ⁼Σιθ

Try it online! Link is to verbose version of code. Takes input in the order GrandTotal, SplitCount, LowerLimit, UpperLimit. Explanation:

NθNηNζ

Input the grand total, split count and lower limit.

≔⊕⁻Nζε

Input the upper limit and calculate the length of the inclusive range from the lower limit to the upper limit.

I‽ΦEXεη⁺﹪÷ιXε…⁰ηεζ⁼Σιθ

Generate the Cartesian product of the split count number of inclusive ranges, filter out those whose sum isn't the desired grand total, and output one uniformly at random.

Python 3.8 (pre-release), 116 bytes

-12 bytes thanks to Jitse

Accepts input in the form of GrandTotal,SplitCount,UpperLimit,LowerLimit.
Returns a randomly picked range, as a tuple, from a list of possible ranges.

lambda g,s,u,l:r.choice([p for p in i.product(range(l,u+1),repeat=s)if sum(p)==g])
import random as r,itertools as i

Try it online!

JavaScript (ES6), 85 bytes

Expects (count, lower, upper)(total).

(n,a,b)=>g=(t,k=n,s=t,...o)=>k?g(t,k-1,s-=q=a-Math.random()*(~b+a)|0,...o,q):s?g(t):o

Try it online!

(NB: The function is likely to stack overflow on some test cases. The above test includes some extra recovery code.)

Bash, 164 bytes

echo>0
seq 1 $2|xargs -I, sh -c "rm ,;seq $4 $3|xargs -i sh -c \"<\$((,-1)) sed s/^/{}\ />>,\""
<$2 tr \  +|sed s/+$//|bc|pr -mt $2 -|grep $1$|cut -d\	 -f1|shuf -n1

Try it online!

Burlesque, 49 bytes

r@s1Js2rzjCBf{++g2==}f{{g1j~[}al}sa-.3 0x/rn1.+si

Try it online!

r@s1          # Range from lowerLimit to upperLimit and save to 1
Js2           # Duplicate grandTotal and save to 2
rz            # Range [0, grandTotal]
jCB           # Combinations of SplitCount
f{++g2==}     # Filter for sum == grantTotal
f{{g1j~[}al}  # Filter for all elements in range
sa-.3 0x/rn   # Generate infinite list of random numbers [0, len)
1.+si         # Take 1 and select it

05AB1E, 8 bytes

ŸIãʒOQ}Ω

Inputs in the order UpperLimit,LowerLimit,SplitCount,GrandTotal.

Try it online or verify all test cases (without the ).

Explanation:

Ÿ       # Take the first two (implicit) inputs and push a list in the range
        # [LowerLimit,UpperLimit]
 Iã     # Create all combinations of a size of the third input SplitCount using
        # the cartesian product
   ʒ    # Filter this list of lists by:
    O   #  Sum the list
     Q  #  Check if it's equal to the fourth (implicit) input GrandTotal
   }Ω   # After the filter: pop and leave a random list
        # (which is output implicitly as result)