\documentclass{article}
\usepackage{fontspec}
\setmainfont{Times New Roman}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\usetikzlibrary{intersections}
\usepackage[,left=0cm,right=0cm,top=0cm, bottom=0cm,
paperwidth=12cm,paperheight=15cm]{geometry}
\begin{document}
\begin{figure}[ht]
\centering
\begin{tikzpicture}
\begin{axis}[
axis lines=left, thick, grid=both,
width=0.9\textwidth, height=0.9\textwidth,
xmin=40,xmax=56, ymin=0,ymax=52, y=0.25cm, x=.6cm,
scale only axis, % Chỉ scale phần trục, không scale nhãn
xlabel={Mút phải (Upper Limits) của các nhóm},
ylabel={Tần số tích lũy}
]
% Vẽ đường Ogive
\addplot[color=black, very thick, mark=*, name path=ogive] coordinates {
%nhập tọa độ (mút phải;tần số tích lũy)
(42,4)(44,8)(46,13)(48,23)(50,37)(52,45)(54,50)
};
% Khai báo
\def\comau{50}
\def\hdmot{50}\def\tdmot{37}
\def\hdhai{52}\def\tdhai{45}
\edef\bantrenbon{\directlua{tex.print(\comau*3/4)}}
% Vẽ đường thẳng y=3n/4
\draw[red, dashed, thick, name path=hline]
(0,\bantrenbon) -- (56,\bantrenbon)
node[above right, pos=.9125] {$y=\dfrac{3n}{4}=\bantrenbon$};
% Dựa vào dữ liệu, đường thẳng y=3n/4 nằm giữa (\hdmot;\tdmot) và (\hdhai;\tdhai)
% Ta có thể nội suy tuyến tính để tìm x
\pgfmathsetmacro{\xinter}{
\hdhai + (\bantrenbon - \tdhai)/(\tdhai - \tdmot) * (\hdhai - \hdmot)}
\pgfmathparse{\xinter}
\xdef\xintervalue{\pgfmathresult}
% Vẽ giao điểm
\coordinate (inter) at (axis cs:\xintervalue,\bantrenbon);
\fill[red] (inter) circle (3pt);
\node[above left] at (inter) {($Q_3$; \bantrenbon)};
% Vẽ đường thẳng đứng
\draw[blue, dashed, thick]
(inter) -- (axis cs:\xintervalue,0)
node[below] {$Q_3 \approx \pgfmathprintnumber[fixed,precision=2]
{\xintervalue}$};
\node[above right] at (\xintervalue,0) {$Q_3=$ \xintervalue};
\fill[blue] (\xintervalue,0) circle (2pt);
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}
$\qquad \qquad \rm \LaTeX$ n etc
Thứ Tư, 10 tháng 12, 2025
Tính Q3 (7 nhóm)
Tính Q3 (6 nhóm) bằng phương pháp đồ thị (đường Ogive)
\documentclass{article}
\usepackage{fontspec}
\setmainfont{Times New Roman}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\usetikzlibrary{intersections}
\usepackage[,left=0cm,right=0cm,top=0cm, bottom=0cm,
paperwidth=12cm,paperheight=15cm]{geometry}
\begin{document}
\begin{figure}[ht]
\centering
\begin{tikzpicture}
\begin{axis}[
axis lines=left, thick, grid=both,
width=0.8\textwidth, height=0.8\textwidth,
xmin=0,xmax=32, ymin=0,ymax=42, y=0.25cm, x=0.25cm,
scale only axis, % Chỉ scale phần trục, không scale nhãn
xlabel={Mút phải (Upper Limits) của các nhóm},
ylabel={Tần số tích lũy}
]
% Vẽ đường Ogive
\addplot[color=black, very thick, mark=*, name path=ogive] coordinates {
%nhập tọa độ (mút phải;tần số tích lũy)
(5,8)(10,24)(15,28)(20,34)(25,36)(30,37)
};
% Khai báo
\def\comau{37}
\def\hdmot{10}\def\tdmot{24}
\def\hdhai{15}\def\tdhai{28}
\edef\bantrenbon{\directlua{tex.print(\comau*3/4)}}
% Vẽ đường thẳng y=3n/4
\draw[red, dashed, thick, name path=hline]
(0,\bantrenbon) -- (32,\bantrenbon)
node[above right, pos=0.65] {$y=\dfrac{3n}{4}=\bantrenbon$};
% Dựa vào dữ liệu, đường thẳng y=3n/4 nằm giữa (\hdmot;\tdmot)
%và (\hdhai;\tdhai) ta có thể nội suy tuyến tính để tìm x
\pgfmathsetmacro{\xinter}{\hdhai +
(\bantrenbon - \tdhai)/(\tdhai - \tdmot) * (\hdhai - \hdmot)}
\pgfmathparse{\xinter}
\xdef\xintervalue{\pgfmathresult}
% Vẽ giao điểm
\coordinate (inter) at (axis cs:\xintervalue,\bantrenbon);
\fill[red] (inter) circle (3pt);
\node[above left] at (inter) {($Q_3$, \bantrenbon)};
% Vẽ đường thẳng đứng
\draw[blue, dashed, thick]
(inter) -- (axis cs:\xintervalue,0)
node[below] {$Q_3 \approx \pgfmathprintnumber[fixed,precision=2]
{\xintervalue}$};
\node[above right] at (\xintervalue,0) {$Q_3=$ \xintervalue};
\fill[blue] (\xintervalue,0) circle (2pt);
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}
Thứ Năm, 27 tháng 11, 2025
Thứ Tư, 19 tháng 11, 2025
Chủ Nhật, 16 tháng 11, 2025
Thứ Bảy, 1 tháng 11, 2025
Thứ Năm, 16 tháng 10, 2025
$\rm \LaTeX$ tính tứ phân vị
Download proflycee.zip
\documentclass[12pt]{article}
\usepackage{times}
\usepackage{ProfLycee}
\useproflyclib{pythontex}
\usepackage[paperwidth=10cm,paperheight=2.5cm]{geometry}
\begin{document}
\MedianeQuartilesECC
{30,35,40,45,50,55}
{1,8,0,25,2}
$Q_1 = \ValPremQuartile$\par
Trung v\d i Med $=Q_2= \ValMed$\par
$Q_3 = \ValTroisQuartile$\par
\end{document}
Đăng ký:
Nhận xét (Atom)