Edit in JSFiddle

$(function(){

	var thMonth = ['ม.ค.','ก.พ.','มี.ค.','เม.ย.','พ.ค.','มิ.ย.','ก.ค.','ส.ค.','ก.ย.','ต.ค.','พ.ย.','ธ.ค.'];

	var bpClr = function ()
	{
		$('#bp-stage').empty();
	};

	var bpCalcPct = function (sample, possibility)
	{
		var rs = false;
		sample = parseInt(sample)
		possibility = parseInt(possibility)
		if (sample >= 0 && possibility > 0)
		{
			rs = new Big(1);
			for (var x = 0; x < sample; x++)
			{

				rs = rs.times((possibility - x)/possibility);
			}
			rs = (new Big(1)).minus(rs).times(100);
		}
		return rs;
	}

	var bpGen = function (sample)
	{
		bpClr();
		var $stage = $('#bp-stage');
		sample = parseInt(sample);
		if (sample > 0)
		{
			$stage.append($('<div/>').addClass('alert alert-info').text('สุ่มข้อมูล ' + sample + ' รายการ'));

			if ($('#bp-calc-possibility').length && $('#bp-calc-sample').length && $('#bp-calc-trigger').length)
			{
				$('#bp-calc-possibility').val(365);
				$('#bp-calc-sample').val(sample);
				$('#bp-calc-trigger').trigger('click');
			}
			
			while (sample > 0)
			{
				var $sample = $('<span/>').addClass('sample label label-default')
				.data('name', chance.name({middle:false,prefix:false,}))
				.data('birthday', randomBirthday());
				$sample.text(' ' + $sample.data('name') + ' - ' + $sample.data('birthday').getDate() + ' ' + thMonth[$sample.data('birthday').getMonth()]);
				$sample.prepend($('<span/>').addClass('glyphicon glyphicon-user')).appendTo($stage);

				$sample.data('birthday', (($sample.data('birthday').getMonth() + 1) + '/' + $sample.data('birthday').getDate()));
				$sample.attr('data-birthday', $sample.data('birthday'));

				delete $sample;
				sample--;
			}

		}
		else
		{
			$stage.append($('<div/>').addClass('alert alert-danger').text('Error: ต้องการ @param sample เป็นจำนวนเต็มบวก'));
		}
		delete $stage, sample;
	};

	var bpCheck = function ()
	{
		var $stage = $('#bp-stage'), $sample = $stage.find('.sample');
		if ($sample.length > 0)
		{
			$stage.find('.alert').remove();

			var sample = [], found = {};

			$sample.each(function(i, e){
				sample[i] = $(e).data('birthday');
			});

			for (var x in sample)
			{
				for (var y in sample)
				{
					if (x !== y)
					{
						var ex = sample[x], ey = sample[y];
						if (ex === ey)
						{
							(! (typeof found[ex] !== typeof undefined && typeof found[ex] === typeof [])) 	&& (found[ex] = []);
							(! (found[ex].indexOf(x) >= 0))		&& (found[ex].push(x));
							(! (found[ex].indexOf(y) >= 0))		&& (found[ex].push(y));
						}
						delete ex, ey;
					}
				}
			}
			var countFound = 0;
			for (var z in found)
			{
				countFound++;
				for (var zz in found[z])
				{
					$($sample[found[z][zz]])
					.addClass('label-success match')
					.removeClass('label-default')
					.off('touchstart mouseover')
					.on('touchstart mouseover', function()
					{
						$('.sample').removeClass('hl');
						$('.sample[data-birthday="' +  $(this).attr('data-birthday') + '"]').addClass('hl');
					})
					.off('touchend mouseout')
					.on('touchend mouseout', function()
					{
						$('.sample').removeClass('hl');
					});
				}
			}
			delete sample, found, z;

			if (countFound)
			{
				$stage.append($('<div/>').addClass('alert alert-info').text('พบ ' + countFound + ' วัน'));
			}
			else
			{
				$stage.append($('<div/>').addClass('alert alert-warning').text('ไม่พบวันเกิดที่ตรงกัน'));
			}


			delete countFound;
		}
		else
		{
			bpClr();
			$stage.append($('<div/>').addClass('alert alert-danger').text('Error: ไม่พบข้อมูลสุ่ม'));
		}

		delete $stage, $sample;
	};

	var bpFormCalc = function ()
	{
		var $resultStage = $('#bp-calc-result');
		var possibility = parseInt($('input#bp-calc-possibility').val()), sample = parseInt($('input#bp-calc-sample').val());
		if (possibility > 0 && sample >= 0 && $resultStage.length)
		{
			var result = bpCalcPct(sample, possibility);
			$resultStage.text(result !== false ? result : 'Error');
		}
		else
		{
			$resultStage.length ? $resultStage.text('Error') : alert('Error');
		}
		
	};

	var randomBirthday = function ()
	{
		do
		{
			var rbd = chance.birthday();
		}
	    while (rbd.getDate() === 29 && rbd.getMonth === 1); // ignore Feb 29th
		return rbd;
	};

	$('body').off('click', '#btn-bp-gen')
		.on('click', '#btn-bp-gen', function (){
			bpGen($('#input-bp-gen').val());
		})
		.off('click', '#btn-bp-check')
		.on('click', '#btn-bp-check', bpCheck)
		.off('click', '#btn-bp-clr')
		.on('click', '#btn-bp-clr', bpClr)
		.off('click', '#bp-calc-trigger')
		.on('click', '#bp-calc-trigger', bpFormCalc)
	;


});
<div class="container">
	<div class="row">
		<div class="col-sm-12">
			<div class="panel panel-default" id="panel-bp">
				<div class="panel-heading">
					<h1 class="panel-title">Birthday Problem <small><a href="https://en.wikipedia.org/wiki/Birthday_problem" target="_blank"><span class="glyphicon glyphicon-info-sign text-muted"></span></a></small></h1>
				</div> 
				<div class="panel-body" id="bp-stage"></div>
				<div class="panel-footer form-inline">

					<div class="form-group">
						<div class="input-group">
							<span class="input-group-btn">
								<button id="btn-bp-gen" class="btn btn-info" type="button">สุ่ม</button>
							</span>
							<input type="number" class="form-control text-right" placeholder="จำนวนสุ่ม" id="input-bp-gen" min="1" max="366" value="57">
						</div>
					</div>
					<div class="form-group">
						<button type="button" class="btn btn-warning" id="btn-bp-check">เช็ค</button>
						<button type="button" class="btn btn-default" id="btn-bp-clr">ลบ</button>
					</div>
				</div>
			</div>
		</div>
	</div>
	<div class="row">
		<div class="col-sm-12">
			<div class="panel panel-default" id="panel-bp-calc">
				<div class="panel-heading">
					<h1 class="panel-title">Birthday Problem Calculator</h1>
				</div>
				<div class="panel-body">
					<div class="form-horizontal">
						<div class="form-group">
							<label for="bp-calc-possibility" class="col-sm-4 control-label">ความเป็นไปได้</label>
							<div class="col-sm-8">
								<input type="number" min="1" class="text-right form-control bp-calc-input" id="bp-calc-possibility" placeholder="ความเป็นไปได้">
							</div>
						</div>
						<div class="form-group">
							<label for="bp-calc-sample" class="col-sm-4 control-label">จำนวนกลุ่มตัวอย่าง</label>
							<div class="col-sm-8">
								<input type="number" min="0" class="text-right form-control bp-calc-input" id="bp-calc-sample" placeholder="จำนวนกลุ่มตัวอย่าง">
							</div>
						</div>
						<div class="form-group">
							<label for="" class="col-sm-4 control-label"></label>
							<div class="col-sm-8">
								<button type="button" class="btn btn-warning" id="bp-calc-trigger">คำนวณ</button>
							</div>
						</div>
						<div class="form-group">
							<label for="" class="col-sm-4 control-label">ความเป็นไปได้ตามทฤษฎี (%)</label>
							<div class="col-sm-8">
								<p class="form-control-static text-success text-right" id="bp-calc-result">???</p>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
#panel-bp{margin-top:30px;}
.sample{margin-right:5px; margin-bottom:5px; display:inline-block}
.sample:last-child{margin-right:0px}
.sample.match{cursor:pointer; border:1px solid #CCCCCC;}
.sample.match.hl{border:1px solid #CC4443}
#bp-calc-result{white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}
#bp-calc-result:hover,#bp-calc-result:active{text-overflow:initial; overflow:visible;}

External resources loaded into this fiddle: