Sort by

recency

|

72 Discussions

|

  • + 0 comments
    import numpy as np
    from scipy.stats import mode
    
    n = int(input())
    numbers = list(map(int, input().split()))
    
    m = np.mean(numbers)
    s = round(np.std(numbers),1)
    z = 1.96
    std_error = (s/(np.sqrt(len(numbers))))
    lower = round(m - (z*std_error), 1)
    upper = round(m + (z*std_error), 1)
    
    print(m)
    print(np.median(numbers))
    print(mode(numbers)[0])
    print(s)
    print(f'{lower} {upper}')
    
  • + 0 comments

    Enter your code here. Read input from STDIN. Print output to STDOUT

    import numpy as np import pandas as pd from functools import reduce from scipy.stats import norm

    i = int(input()) l = input() ls = list(map(lambda x: int(x), l.split()))

    def mean(ls, n): return reduce(lambda acc, cur : acc + cur, ls, 0) / n

    def median(ls, n): ls_sort = ls ls_sort.sort() if n % 2 != 0: return ls_sort[int(n / 2)]

    return (ls_sort[int(n / 2)] + ls_sort[int(n / 2) - 1]) / 2
    

    def mode(ls, n): keys = list(set(ls)) keys.sort() freq_el = {} for key in keys: freq_el[key] = 0

    for el in ls:
        freq_el[el] += 1
    
    sorted_freq = dict(sorted(freq_el.items(), key = lambda item : item[1], reverse = True))
    
    return list(sorted_freq.keys())[0]
    

    def std(ls, n): m = mean(ls, n) st = ((reduce(lambda acc, cur: acc + (cur - m)**2 , ls, 0)) / n)**0.5 return round(st, 1)

    def Confidence_Interval(ls, n): m = mean(ls, n) st = std(ls, n) # z_score = norm.ppf(0.975) z_score = 1.96

    upperBound = m + z_score * (st / n**0.5)
    
    lowerBound = m - z_score * (st / n**0.5)
    
    return (round(lowerBound, 1), round(upperBound, 1))
    

    print(mean(ls, i))
    print(median(ls, i))
    print(mode(ls, i))
    print(std(ls, i)) print(*Confidence_Interval(ls, i))

  • + 0 comments

    We have built an enterprise ai platform - Centralized platform for quickly and securely deploying Generative & Classic AI in your enterprise. Choose from ready-to-deploy AI Applications, AI agents, build your own, or let us create tailored solutions for your enterprise needs. Empower your teams with AI-driven enterprise search and instant answers, no matter where your knowledge resides. OnDemand Console transforms the management of assets, devices, and networks through intuitive, conversational control. Manage any data—IoT, finance, business, and more—through natural language interactions. A completely dynamic UI that instantly generates widgets based on your natural language requests. You can ask for any graph, report, analytics, or prediction, and it’s presented to you instantly. No-learning-curve https://studiox-ai.com

  • + 1 comment
    import pandas as pd
    import numpy as np
    import math
    
    def custom_round(num, decimals=0):
        factor = 10 ** decimals
        return math.floor(num * factor + 0.5) / factor
    
    i = input()
    s = input()
    l = list(map(int, s.split(" ")))
    numbers_series = pd.Series(l)
    
    #Calculate the mean
    mean = numbers_series.mean()
    print(f"{custom_round(mean,1):.1f}")
    
    #Median
    print(f"{custom_round(numbers_series.median(),1):.1f}")
    
    #mode (which is a lsit)
    mode = numbers_series.mode()
    print(f"{mode[0]}")
    
    std = numbers_series.std(ddof=0)
    print(f"{custom_round(std,1):.1f}")
    
    
    #Find the critical value for a 95% confidence interval
    margin_of_error = 1.96 * (std / (len(numbers_series) ** 0.5))
    #margin_of_error = confidence_level * (std/(np.sqrt(len(numbers_series))))
    
    #Calculate the confidence interval
    lower_bound = mean - margin_of_error
    upper_bound = mean + margin_of_error
    
    print(f"{custom_round(lower_bound,1):.1f} {custom_round(upper_bound,1):.1f}")
    
    • + 1 comment

      The rounding was killing me

      Also thew questions was 95% confidence interval, but we use 1.96???

      • + 0 comments

        Read on critical values

  • + 0 comments
    # Enter your code here. Read input from STDIN. Print output to STDOUT
    import sys
    import numpy as np
    from scipy import stats
    
    # Read Data
    data = sys.stdin.read().splitlines()
    nums = data[1].split(' ')
    nums = np.array([int(num) for num in nums])
    
    # Calculate Stats
    mean = np.mean(nums)
    median = np.median(nums)
    mode = stats.mode(nums)[0]
    std = np.std(nums)
    z = 1.96
    std_error = (std/(np.sqrt(len(nums))))
    lower = mean - z*std_error
    upper = mean + z*std_error
    
    # Print Output
    print(f"{mean:.1f}")
    print(f"{median:.1f}")
    print(mode)
    print(f"{std:.1f}")
    print(f"{lower:.1f} {upper:.1f}")