This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Licensed to the Apache Software Foundation (ASF) under one | |
# or more contributor license agreements. See the NOTICE file | |
# distributed with this work for additional information | |
# regarding copyright ownership. The ASF licenses this file | |
# to you under the Apache License, Version 2.0 (the | |
# "License"); you may not use this file except in compliance | |
# with the License. You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
retorna_media <- function (lista) { | |
media <- as.integer(mean(lista)) | |
return (media) | |
} | |
retorna_media(lista=empregados$lista_idade) | |
# Media de idade: 45 | |
retorna_media(lista=empregados$lista_salarios) | |
# Media de salarios: 9830 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Nova distribuição seguindo o intervalo ate 18 ate 100 anos | |
distribuicao <- function(n) as.integer(sample(18:100, n)) | |
numero_registros_base <- nrow(empregados) | |
distribuicao(numero_registros_base) | |
lista_registros <- empregados$lista_idade | |
mecanismo_resposta_privado <- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sensibilidade <- | |
resposta_privacidade_diferencial$sensitivity | |
dimensoes <- | |
resposta_privacidade_diferencial$dims | |
parametros_privacidade <- | |
resposta_privacidade_diferencial$privacyParams | |
resposta_com_privacidade <- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resposta_privacidade_diferencial <- | |
releaseResponse(mechanism = mecanismo_resposta_privado, | |
privacyParams = DPParamsEps(epsilon = 1), | |
X = empregados$lista_salarios) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mecanismo_resposta_privado@sensitivity | |
mecanismo_resposta_privado@dims | |
mecanismo_resposta_privado@gammaSensitivity | |
mecanismo_resposta_privado@target(empregados$lista_salarios) | |
mecanismo_resposta_privado@target(empregados$lista_idade) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mecanismo_resposta_privado <- | |
sensitivitySampler(object = mecanismo_privacidade, | |
oracle = distribuicao, | |
n = numero_registros_base, | |
m = 4, | |
gamma = 0.7) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
distribuicao <- function(n) as.integer(rnorm(n)*10000) | |
numero_registros_base <- nrow(empregados) | |
distribuicao(numero_registros_base) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mecanismo_privacidade <- | |
DPMechLaplace(sensitivity = c(Inf), | |
target = retorna_media, | |
gammaSensitivity = c(NA_real_), | |
dims = c(NA_integer_)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
retorna_media <- function (lista) { | |
media <- as.integer(mean(lista)) | |
return (media) | |
} | |
retorna_media(lista=empregados$lista_idade) | |
# Media de idade: 45 | |
retorna_media(lista=empregados$lista_salarios) | |
# Media de salarios: 9830 |