Skip to content
TheChatArchiveThe Chat Archive
Claudeclaude-sonnet-4-20250514· AnthropicHugging Face LMArena Human Preference 140K

Sorry, I actually want to plot the final number of infections under each beta value…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Amazon Novaamazon.nova-pro-v1:0’s answer.
  1. User

    Sorry, I actually want to plot the final number of infections under each beta value while using my exact simulation function above, unless that provides an error? That simulation funciton should provide a table of the node and time it becomes infected. So I want this final code to be corrected to accurately plot my final infection values at each beta level

    results <- map_dfr(seq(0,0.2,0.01), # beta range (beta){ seeds <- sample(1:vcount(g),vcount(g)*0.01) realization <- sim_sir(g,beta,mu,seeds) # make a realization for each beta data.frame(beta,ninf=nrow(realization)) # create dataframe row }) results %>% ggplot(aes(x=beta,y=ninf))+ geom_point()+ geom_vline(xintercept = betac,linetype=2)

  2. Claude Assistant

    Looking at your code, there are a few issues to fix:

    1. You're using g but defined graph_undirected
    2. You're redefining seeds inside the map function, overriding your original seeds
    3. You need to define betac for the vertical line

    Here's the corrected code:

    # Keep recovery rate (mu) at 0.1
    mu <- 0.1
    
    # Set seeds once (randomly set 1% as seeds)
    set.seed(123)
    num_seeds <- ceiling(0.01 * vcount(graph_undirected))
    seeds <- sample(1:vcount(graph_undirected), num_seeds)
    
    # Define betac (critical beta value) - you'll need to set this based on your network
    # For example, if you know the critical value or want to highlight a specific beta:
    betac <- 0.1  # Adjust this value as needed
    
    # Produce summary results and plot
    results <- map_dfr(seq(0, 0.2, 0.01), # beta range
            \(beta){ 
            realization <- sim_sir(graph_undirected, beta, mu, seeds) # use consistent graph name and fixed seeds
            data.frame(beta, ninf = nrow(realization)) # create dataframe row
            })
    
    results %>% 
      ggplot(aes(x = beta, y = ninf)) + 
      geom_point() +
      geom_vline(xintercept = betac, linetype = 2) +
      labs(title = "Final Number of Infections by Beta Value",
           x = "Beta (Transmission Rate)",
           y = "Total Number of Infections") +
      theme_minimal()
    

    The key changes:

    • Used graph_undirected consistently instead of g
    • Removed the seeds <- sample(...) line from inside the map function so you use the same initial seeds for all beta values
    • Added betac definition (you'll need to set this to your desired critical value)
    • Added proper labels to the plot

    This will now correctly show how the final number of infections varies with different beta values while keeping the initial conditions (seeds) constant across all simulations.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.