public final String getPerformanceSuggestion() { double prob = MCMCOperator.Utils.getAcceptanceProbability(this); double targetProb = getTargetAcceptanceProbability(); double sf = OperatorUtils.optimizeScaleFactor(scaleFactor, prob, targetProb); dr.util.NumberFormatter formatter = new dr.util.NumberFormatter(5); if (prob < getMinimumGoodAcceptanceLevel()) { return "Try setting scaleFactor to about " + formatter.format(sf); } else if (prob > getMaximumGoodAcceptanceLevel()) { return "Try setting scaleFactor to about " + formatter.format(sf); } else return ""; }
public byte[] generateWrappedKey(GenericKey encryptionKey) throws OperatorException { Key contentEncryptionKeySpec = OperatorUtils.getJceKey(encryptionKey); Cipher keyEncryptionCipher = helper.createSymmetricWrapper(this.getAlgorithmIdentifier().getAlgorithm()); try { keyEncryptionCipher.init(Cipher.WRAP_MODE, wrappingKey, random); return keyEncryptionCipher.wrap(contentEncryptionKeySpec); } catch (InvalidKeyException e) { throw new OperatorException("cannot wrap key: " + e.getMessage(), e); } catch (GeneralSecurityException e) { throw new OperatorException("cannot wrap key: " + e.getMessage(), e); } }