我想从定义消息协议的字符串中获取原型描述符。例如我有:
public final static String schema = ""
+ "message Person {\n"
+ " required string id = 1;\n"
+ " required string name = 2;\n"
+ "}";
@Test
public void dynamicProto() throws IOException {
DescriptorProtos.DescriptorProto descriptor = DescriptorProtos.DescriptorProto.parseFrom(schema.getBytes());
boolean test = true;
//do stuff
}
Run Code Online (Sandbox Code Playgroud)
我收到以下异常: com.google.protobuf.InvalidProtocolBufferException:协议消息标记的线路类型无效。
最终,我希望能够定义一个模式并在运行时接受实际的原始消息,而不是在编译时接受某些模拟服务类型的内容。
使用从示例中获取的以下代码......我如何获得您在 Excel 等输出中找到的 p 值和 t-stat?
OLSMultipleLinearRegression regression2 = new OLSMultipleLinearRegression();
double[] y = { 4, 8, 13, 18};
double[][] x = {{ 1, 1, 1 },
{ 1, 2, 4 },
{ 1, 3, 9 },
{ 1, 4, 16 }};
regression2.newSampleData(y, x);
regression2.setNoIntercept(true);
double[] beta = regression2.estimateRegressionParameters();
for (double d : beta) {
System.out.println("D: " + d);
}
Run Code Online (Sandbox Code Playgroud)
发布这个问题后,我解决了 t-stat 部分:
for (int i=0; i < beta.length; i++){
double tstat = beta[i] / regression.estimateRegressionParametersStandardErrors()[i];
System.out.println("t-stats(" +i +") : …Run Code Online (Sandbox Code Playgroud)