Skip to content

Instantly share code, notes, and snippets.

#
# Initially infer Hoeffding's Inequality.
#
from scipy import signal
import numpy as np
import math
import pandas as pd
import matplotlib.pyplot as plt
#
# Draw the Hoeffding's Inequality with the epsilons = 0.3 and the probability.
#
from scipy import signal
import numpy as np
import math
def hoeffding (x, epsilon):
y = 2.0 * math.exp (-2*epsilon*epsilon*x)
#
# Draw the Hoeffding's Inequality with different epsilons, 0.1, 0.3, 0.5, and 1.
#
from scipy import signal
import numpy as np
import math
def hoeffding (x, epsilon):
y = 2.0 * math.exp (-2*epsilon*epsilon*x)
#
# Use random numbers to emulates the Sampling with Replacement.
#
# We can specify the number of balls in the bin with 40% red balls and 60% green balls.
# We select 10 balls from the bin and calculate the probability of the red
# balls in the samples.
#
import random
@CountChu
CountChu / Bin3.py
Created November 16, 2017 16:15
Peak balls from a bin (Sampling wihtout Replacement)
#
# Peak balls from a bin (Sampling wihtout Replacement)
#
import math
import matplotlib.pyplot as plt
import numpy as np
#
# n Choice r
@CountChu
CountChu / Setup.py
Created October 23, 2016 09:44
Avoid cx_Freeze generating Library.zip
import sys
import os
from cx_Freeze import setup, Executable
Exe1 = Executable (
script=r"MyApp\MyApp.py",
base=None,
appendScriptToExe = True,
appendScriptToLibrary = False,
)
@CountChu
CountChu / Layout.py
Last active October 23, 2016 07:19
Apply HTML coding habit in wxPython sizer for UI layout
def __init__ (self):
wx.Frame.__init__ (self, None, -1, self.Title)
if "<TABLE>":
self.Hs = wx.BoxSizer (wx.VERTICAL)
if "<TR>":
self.St = wx.StaticText(self, label="Your name :", pos=(20,60))
@CountChu
CountChu / ChgEnv.bat
Last active October 23, 2016 07:30
Use Python to change a system environment variable
python ChgEnv.py %1
call Temp.bat