How to make rarities with dictionary

How would I make a function that returns a random name staying true to percentages provided in the Rarities dictionary?

local Common = {"Josh","Mark","Jhon","Angel"}

local Uncommon = {"Toby","Luke","Micheal"}

local Rare = {"Kamina","Georgypoo"}

local Legendary = {"Woof Woof"}

local Ascended = {"GRRR WOOF WOOF"}

local Rarities = {

    Common = 70,

    Uncommon = 25,

    Rare = 4,

    Legendary = 0.9,

    Ascended = 0.1

}

This is a great example of a rarity/weighted item set up:

You could generate a number between 1-1000 and check if the number is in a range.

local Common = {"Josh","Mark","Jhon","Angel"}
local Uncommon = {"Toby","Luke","Micheal"}
local Rare = {"Kamina","Georgypoo"}
local Legendary = {"Woof Woof"}
local Ascended = {"GRRR WOOF WOOF"}

local Rarities = {
    Common = 70,
    Uncommon = 25,
    Rare = 4,
    Legendary = 0.9,
    Ascended = 0.1
}

function PickRandom()
	local RandomNum = math.random(0, 1000)
	local Num1 = 0
	local Num2 = 0
	for i, v in pairs(Rarities) do
		Num1 += v * 10
		if RandomNum <= Num1 and RandomNum >= Num2 then
			print(i)
			return i
		end
		Num2 += v * 10
	end
end