R积分问题:非有限函数值

时间:2017-08-21 23:03:04

标签: r integrate weibull

我一直在努力将weibull分布从0整合到给定值,以根据分布模型估算故障率。我所有的尝试都给了我"非有限函数值"错误 我试图使用ifelse和sapply,但都未能解决问题..

到目前为止,这是我的代码:

public static class DummyFragment extends Fragment {
    int color;

    public DummyFragment() {
    }

    @SuppressLint("ValidFragment")
    public DummyFragment(int color) {
        this.color = color;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.dummy_fragment, container, false);
        final RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.dummyfrag_scrollableview);
        final FrameLayout frameLayout = (FrameLayout) view.findViewById(R.id.dummyfrag_bg);
        frameLayout.setBackgroundColor(color);
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity().getBaseContext());
        recyclerView.setLayoutManager(linearLayoutManager);
        recyclerView.setHasFixedSize(true);

        DatabaseReference mDatabaseGig;
        final List<Dessert> dessertList;
        // get the gig database
        mDatabaseGig = FirebaseDatabase.getInstance().getReference("Gig Posts");
        dessertList = new ArrayList<>();
        DessertAdapter adapter = new DessertAdapter(getContext(), dessertList);
        recyclerView.setAdapter(adapter);

        mDatabaseGig.addValueEventListener(new ValueEventListener() {
            @Override
            public void onDataChange(DataSnapshot dataSnapshot) {

               // dessertList.clear();

                for(DataSnapshot gigSnapshot: dataSnapshot.getChildren()){
                    Dessert dessert = gigSnapshot.getValue(Dessert.class);
                    dessertList.add(dessert);
                    adapter.notifyDataSetChanged();
                }

            }

            @Override
            public void onCancelled(DatabaseError databaseError) {

            }
        });





        // possible to put progress dialogue



        return view;
    }
}

如果我遗漏任何明显的东西,请告诉我。

1 个答案:

答案 0 :(得分:0)

您需要声明beta1和alpha1。试试这个:

f <- function (y, alpha1, beta1) {
    (beta1/y) * ((y/alpha1)^beta1) * exp(-((y/alpha1)^beta1)) 
}
f1 <- function (y, alpha1, beta1) {
    sapply(y,f, alpha1, beta1)
}
R <- integrate(f1, 1e-10, 10, alpha1 = 1, beta1 = 0.9)

您可以迭代alpha1和beta1值。