Hello, please, I need to calculate the indicator function as I underlined in my attached pdf file but I can't define a code in programming language that deals with this case. Please help me with a code whether it's in python or R can help me. Sincerely. -------------- next part -------------- A non-text attachment was scrubbed... Name: code algo test.pdf Type: application/pdf Size: 145210 bytes Desc: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20210129/19b0dec7/attachment.pdf>
Is this a homework problem? The posting guide linked below explicitly says: "*Basic statistics and classroom homework:* R-help is not intended for these." Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Fri, Jan 29, 2021 at 2:20 PM Ablaye Ngalaba <ablayengalaba at gmail.com> wrote:> Hello, > please, I need to calculate the indicator function as I underlined in my > attached pdf file but I can't define a code in programming language that > deals with this case. Please help me with a code whether it's in python or > R can help me. > > > > Sincerely. > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]
Perhaps (in R): n_i <- cumsum( Y==l ) You should read further regarding R's logical class, and operators that work on it, and how it is coerced. -- David On 1/29/21 6:27 AM, Ablaye Ngalaba wrote:> Hello, > please, I need to calculate the indicator function as I underlined in my > attached pdf file but I can't define a code in programming language that > deals with this case. Please help me with a code whether it's in python or > R can help me. > > > > Sincerely. > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.[[alternative HTML version deleted]]
Hello, Maybe this? n_l <- function(Y, l, na.rm = FALSE) sum(Y == l, na.rm = na.rm) set.seed(2020) q <- 6 y <- sample(q, 10, TRUE) l <- 4 n_l(y, l) #[1] 3 Hope this helps, Rui Barradas ?s 14:27 de 29/01/21, Ablaye Ngalaba escreveu:> Hello, > please, I need to calculate the indicator function as I underlined in my > attached pdf file but I can't define a code in programming language that > deals with this case. Please help me with a code whether it's in python or > R can help me. > > > > Sincerely. > > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >