代码拉取完成,页面将自动刷新
同步操作将从 openKylin/cybersectookits 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
# -*- coding: utf-8 -*-
"""
@Time : 2022/8/7 16:02
@Author : Mr Wang
@FileName: test.py
@SoftWare: PyCharm
"""
# -*- coding: utf-8 -*-
"""
@Time : 2022/5/15 17:56
@Author : Mr Wang
@FileName: UE_new.py
@SoftWare: PyCharm
"""
# -*- coding: utf-8 -*-
"""
@Time : 2022/1/16 15:33
@Author : Mr Wang
@FileName: New.py
@SoftWare: PyCharm
"""
import random
import numpy as np
number =3 # 随机数数量
bits = 8 # 多少位
UB = 100.88
LB = 20.36 # 预估
def perturb1(epsilon, value, m, n=2):
a=5
p = 1 / (a+1) # 概率p
np.random.seed(m)
# 以p的概率生成value,1-p的概率非value
p = np.array([p, 1 - p])
index = np.random.choice([value, 1 - value], p=p.ravel())
return str(index)
def perturb2(epsilon, value, m, n=2):
a=5
p = a*np.e ** (epsilon / (number * bits)) / (a*np.e ** (epsilon / (number * bits)) + n - 1) # 概率p
np.random.seed(m)
# 以p的概率生成value,1-p的概率非value
p = np.array([p, 1 - p])
index = np.random.choice([value, 1 - value], p=p.ravel())
return str(index)
d = (UB-LB) / bits
def main(rnd_list):
binary_perturb = [0] * number
final = [0] * number
op_list = ['0'] * bits
binary_list = [0] * number
for i in range(0, number):
for j in range(0,bits):
if rnd_list[i] >= UB:
op_list = ['1'] * bits
if (rnd_list[i] >= LB+ d * j) & (rnd_list[i] < LB + d * (j + 1)):
k = j
for m in range(0, k):
op_list[m] = '1'
# print(op_list)
str1 = ''.join(op_list)
binary_list[i] = str1
op_list = ['0'] * bits
aa = ''.join(binary_list)
print(binary_list)
# print(aa)
bb = [0] * (bits*number)
for i in range(len(aa)):
if aa[i] == '1':
bb[i] = perturb1(1, int(aa[i]), i)
if aa[i] == '0':
bb[i] = perturb2(1, int(aa[i]), i)
# print(bb)
oplist = []
for i in range(0, number):
for j in range(i * bits, (i + 1) * bits):
oplist.append(bb[j])
# print(oplist)
str1 = ''.join(oplist)
binary_perturb[i] = str1
oplist = []
# print(binary_perturb)
for i in range(0, number):
for x in binary_perturb[i]:
if x == '1':
sum = binary_perturb[i].count(x)
final[i] = LB+ sum * d
sum = 0
print(final)
if __name__ == '__main__':
main([20,32.25,88.999])
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。